示例#1
0
  protected void tearDown() throws Exception {
    // now close logix window
    TestHelper.disposeWindow(_logixTable.editLogixFrame, this);
    // now close logix actin window
    TestHelper.disposeWindow(_logixTable.f, this);

    JUnitUtil.resetInstanceManager();
    super.tearDown();
    apps.tests.Log4JFixture.tearDown();
  }
示例#2
0
  @SuppressWarnings("unchecked")
  public void testShowAndClose() throws Exception {
    jmri.configurexml.ConfigXmlManager cm = new jmri.configurexml.ConfigXmlManager() {};

    // load and display sample file
    java.io.File f =
        new java.io.File(
            "java/test/jmri/jmrit/display/layoutEditor/valid/SimpleLayoutEditorTest.xml");
    cm.load(f);
    sleep(100); // time for internal listeners to calm down

    // Find new window by name (should be more distinctive, comes from sample file)
    LayoutEditor le = (LayoutEditor) jmri.util.JmriJFrame.getFrame("My Layout");

    // It's up at this point, and can be manipulated
    // Ask to close window
    TestHelper.disposeWindow(le, this);

    // Dialog has popped up, so handle that. First, locate it.
    List<JDialog> dialogList = new DialogFinder(null).findAll(le);
    JDialog d = dialogList.get(0);

    // Find the button that deletes the panel
    AbstractButtonFinder finder = new AbstractButtonFinder("Delete Panel");
    JButton button = (JButton) finder.find(d, 0);
    Assert.assertNotNull(button);

    // Click button to delete panel and close window
    getHelper().enterClickAndLeave(new MouseEventData(this, button));

    // another dialog has popped up, so handle that by finding the "Yes - Delete" button.
    dialogList = new DialogFinder(null).findAll(le);
    d = dialogList.get(0);
    finder = new AbstractButtonFinder("Yes - Delete");
    button = (JButton) finder.find(d, 0);
    Assert.assertNotNull(button);

    // Click to say yes, I really mean it.
    getHelper().enterClickAndLeave(new MouseEventData(this, button));
  }
示例#3
0
 protected void tearDown() throws Exception {
   testPanel = null;
   finder = null;
   TestHelper.cleanUp(this);
   super.tearDown();
 }
示例#4
0
 protected void tearDown() throws Exception {
   leaveAllWindowsOpen();
   TestHelper.cleanUp(this);
   super.tearDown();
 }
示例#5
0
 protected void leaveAllWindowsOpen() {
   TestHelper.addSystemWindow("."); // all windows left open
 }
示例#6
0
  public void testCreateLogix() throws Exception {
    // Setting these two prevents any pop up message generated by the system trying to save
    // messages.
    jmri.InstanceManager.getDefault(jmri.UserPreferencesManager.class)
        .setPreferenceState("jmri.managers.DefaultUserMessagePreferences", "reminder", true);
    jmri.InstanceManager.getDefault(jmri.UserPreferencesManager.class)
        .setPreferenceState("jmri.jmrit.beantable.LogixTableAction", "remindSaveLogix", true);

    jmri.InstanceManager.store(
        new jmri.jmrit.signalling.EntryExitPairs(), jmri.jmrit.signalling.EntryExitPairs.class);

    try {
      _logixTable.prefMgr = jmri.InstanceManager.getDefault(jmri.UserPreferencesManager.class);
      _logixTable.actionPerformed(null);
      _logixTable.addPressed(null);
      _logixTable._addUserName.setText("TestLogix");
      _logixTable._systemName.setText("TX");
      _logixTable._autoSystemName.setSelected(false);
      _logixTable.createPressed(null);
      _logixTable.donePressed(null);
      // note: _logixTable.m.EDITCOL = BeanTableDataModel.DELETECOL
      _logixTable.m.setValueAt(rbx.getString("ButtonEdit"), 0, BeanTableDataModel.DELETECOL);
      _logixTable.newConditionalPressed(null);
      // _logixTable.helpPressed(null);
      _logixTable.conditionalUserName.setText("TestConditional");
      _logixTable.updateConditionalPressed(null);

      // now close window
      // TestHelper.disposeWindow(_logixTable.editConditionalFrame,this);
      _logixTable.newConditionalPressed(null);
      _logixTable.conditionalTableModel.setValueAt(
          null, 0, LogixTableAction.ConditionalTableModel.BUTTON_COLUMN);
      for (int i = 0; i < 2; i++) {
        _logixTable.addVariablePressed(null);
        _logixTable._variableTypeBox.setSelectedIndex(Conditional.ITEM_TYPE_SENSOR);
        _logixTable._variableStateBox.setSelectedIndex(i);
        _logixTable._variableNameField.setText("IS" + i);
        _logixTable.updateVariablePressed();
      }
      for (int i = 0; i < 2; i++) {
        _logixTable.addVariablePressed(null);
        _logixTable._variableTypeBox.setSelectedIndex(Conditional.ITEM_TYPE_TURNOUT);
        _logixTable._variableStateBox.setSelectedIndex(i);
        _logixTable._variableNameField.setText("Turnout" + i);
        _logixTable.updateVariablePressed();
      }
      for (int i = 0; i < 2; i++) {
        _logixTable.addVariablePressed(null);
        _logixTable._variableTypeBox.setSelectedIndex(Conditional.ITEM_TYPE_LIGHT);
        _logixTable._variableStateBox.setSelectedIndex(i);
        _logixTable._variableNameField.setText("IL" + i);
        _logixTable.updateVariablePressed();
      }
      for (int i = 0; i < 2; i++) {
        _logixTable.addVariablePressed(null);
        _logixTable._variableTypeBox.setSelectedIndex(Conditional.ITEM_TYPE_CONDITIONAL);
        _logixTable._variableStateBox.setSelectedIndex(i);
        _logixTable._variableNameField.setText("C" + i);
        _logixTable.updateVariablePressed();
      }
      /* SignalHead code changed - test cannot be done this way
      Must implement from UI dialogs to get the right info to updateVariablePressed()
      for (int i=0; i<9; i++){
      if (i==3 || i==7) {        // lunar aspects
      continue;
      }
      _logixTable.addVariablePressed(null);
      _logixTable._variableTypeBox.setSelectedIndex(Conditional.ITEM_TYPE_SIGNALHEAD);
      _logixTable._variableStateBox.setSelectedIndex(i);
      _logixTable._variableNameField.setText("Signal"+i);
      _logixTable.updateVariablePressed();
      }
      */
      _logixTable.addActionPressed(null);
      _logixTable.cancelEditActionPressed();

      _logixTable.addActionPressed(null);
      _logixTable._actionItemTypeBox.setSelectedIndex(Conditional.ITEM_TYPE_TURNOUT);
      _logixTable._actionTypeBox.setSelectedIndex(1); // ACTION_SET_TURNOUT
      _logixTable._actionOptionBox.setSelectedIndex(2); // on false
      _logixTable._actionNameField.setText("Turnout3");
      _logixTable._actionBox.setSelectedIndex(0); // Turnout.CLOSED
      _logixTable.updateActionPressed();
      /*
      // Test is done and turnoutManagerInstance gone by the time the timer goes off
      _logixTable.addActionPressed(null);
      _logixTable._actionItemTypeBox.setSelectedIndex(Conditional.ITEM_TYPE_TURNOUT);
      _logixTable._actionTypeBox.setSelectedIndex(2);         // ACTION_DELAYED_TURNOUT
      _logixTable._actionOptionBox.setSelectedIndex(1);       // on false
      _logixTable._actionNameField.setText("IT4");
      _logixTable._actionBox.setSelectedIndex(1);             // Turnout.THROWN
      _logixTable._shortActionString.setText("1");           // delay 1 sec
      _logixTable.updateActionPressed();
      */
      _logixTable.addActionPressed(null);
      _logixTable._actionItemTypeBox.setSelectedIndex(Conditional.ITEM_TYPE_TURNOUT);
      _logixTable._actionTypeBox.setSelectedIndex(3); // ACTION_LOCK_TURNOUT
      _logixTable._actionOptionBox.setSelectedIndex(0); // on false
      _logixTable._actionNameField.setText("Turnout5");
      _logixTable._actionBox.setSelectedIndex(2);
      _logixTable.updateActionPressed();

      _logixTable.updateConditionalPressed(null);

      // move on to another
      assertEquals(
          "State Variable count", 8, _logixTable._curConditional.getCopyOfStateVariables().size());
      assertEquals("Action count", 2, _logixTable._curConditional.getCopyOfActions().size());
      _logixTable.newConditionalPressed(null);
      // _logixTable.helpPressed(null);
      _logixTable.conditionalUserName.setText("SecondConditional");
      _logixTable.updateConditionalPressed(null);

      Assert.assertEquals("Conditional count", 1, _logixTable._curLogix.getNumConditionals());
      // _logixTable.donePressed(null);

      // note: _logixTable.m.EDITCOL = BeanTableDataModel.DELETECOL
      // _logixTable.m.setValueAt(rbx.getString("ButtonEdit"), 0, BeanTableDataModel.DELETECOL);
      _logixTable.conditionalTableModel.setValueAt(
          null, 0, LogixTableAction.ConditionalTableModel.BUTTON_COLUMN);
      _logixTable.conditionalUserName.setText("FirstConditional");
      _logixTable.updateConditionalPressed(null);

      _logixTable.calculatePressed(null);
      _logixTable.donePressed(null);

      // now close window
      TestHelper.disposeWindow(_logixTable.editConditionalFrame, this);

    } catch (Exception ex) {
      ex.printStackTrace();
      throw ex;
    }
  }