source: tmcsimulator/trunk/test/tmcsim/simulationmanager/IncidentHistoryPanelTest.java @ 11

Revision 11, 2.1 KB checked in by jdalbey, 10 years ago (diff)

Add unit test for IncidentHistoryPanel?

Line 
1package tmcsim.simulationmanager;
2
3import java.util.Vector;
4import static junit.framework.Assert.assertEquals;
5import junit.framework.TestCase;
6import org.uispec4j.*;
7import tmcsim.cadmodels.*;
8import tmcsim.client.cadclientgui.data.IncidentEvent;
9
10/**
11 *
12 * @author jdalbey
13 */
14public class IncidentHistoryPanelTest extends TestCase
15{
16
17    public IncidentHistoryPanelTest(String testName)
18    {
19        super(testName);
20    }
21
22    @Override
23    protected void setUp() throws Exception
24    {
25        super.setUp();
26    }
27
28    /**
29     * Test of updateIncidentHistory method, of class IncidentHistoryPanel.
30     */
31    public void testUpdateIncidentHistory()
32    {
33        System.out.println("updateIncidentHistory");
34        IncidentHistoryPanel ihPanel = new IncidentHistoryPanel();
35        Panel inciPanel = new Panel(ihPanel);
36        TextBox txtType = inciPanel.getTextBox("incTypeTF");
37        TextBox txtLoc = inciPanel.getTextBox("incLocTF");
38        // verify fields initially empty
39        assertEquals("", txtType.getText());
40        assertEquals("", txtLoc.getText());
41
42        // Build an Incident to put in the log
43        Vector dummy = new Vector();
44        IncidentInquiryHeader hdr = new IncidentInquiryHeader();
45        hdr.type = "1179";
46        hdr.fullLocation = "Computer Science Bldg";
47        IncidentInquiryModel_obj mo = new IncidentInquiryModel_obj();
48        mo.setHeader(hdr);
49        IncidentInquiryDetails det = new IncidentInquiryDetails("1", "Happy Programmer", false);
50        mo.addDetail(det);
51        IncidentEvent event = new IncidentEvent(10, mo, "", 4, dummy, dummy);
52        ihPanel.updateIncidentHistory(event);
53
54        // After adding an event, verify fixed fields
55        assertEquals("1179", txtType.getText());
56        assertEquals("Computer Science Bldg", txtLoc.getText());
57        // Verify first row of log history table
58        Table evtLog = inciPanel.getTable("LogHistory");
59//        System.out.println(evtLog.toString());
60        assertEquals(1, evtLog.getJTable().getRowCount());
61        assertEquals("Script", evtLog.getContentAt(0, 0));
62        assertEquals("Happy Programmer", evtLog.getContentAt(0, 2));
63    }
64}
Note: See TracBrowser for help on using the repository browser.