Search in sources :

Example 11 with UserPreferencesManager

use of jmri.UserPreferencesManager in project JMRI by JMRI.

the class JmriUserPreferencesManagerTest method testSetSaveAllowed.

@Test
public void testSetSaveAllowed() {
    UserPreferencesManager m = new JmriUserPreferencesManager();
    m.setSaveAllowed(false);
    Assert.assertFalse(m.isSaveAllowed());
    m.setSaveAllowed(true);
    Assert.assertTrue(m.isSaveAllowed());
}
Also used : UserPreferencesManager(jmri.UserPreferencesManager) Test(org.junit.Test)

Example 12 with UserPreferencesManager

use of jmri.UserPreferencesManager in project JMRI by JMRI.

the class JmriUserPreferencesManagerTest method testGetPropertyKeys.

@Test
public void testGetPropertyKeys() {
    UserPreferencesManager m = new JmriUserPreferencesManager();
    m.setSaveAllowed(false);
    Assert.assertNull(m.getPropertyKeys(strClass));
    m.setProperty(strClass, "test1", log);
    m.setProperty(strClass, "test2", null);
    Assert.assertEquals(2, m.getPropertyKeys(strClass).size());
    Assert.assertTrue(m.getPropertyKeys(strClass).contains("test1"));
    Assert.assertTrue(m.getPropertyKeys(strClass).contains("test2"));
    Assert.assertFalse(m.getPropertyKeys(strClass).contains("test3"));
}
Also used : UserPreferencesManager(jmri.UserPreferencesManager) Test(org.junit.Test)

Example 13 with UserPreferencesManager

use of jmri.UserPreferencesManager in project JMRI by JMRI.

the class JmriUserPreferencesManagerTest method testAllowSave.

@Test
public void testAllowSave() {
    UserPreferencesManager m = new JmriUserPreferencesManager();
    m.setSaveAllowed(false);
    Assert.assertFalse(m.isSaveAllowed());
    m.allowSave();
    Assert.assertTrue(m.isSaveAllowed());
}
Also used : UserPreferencesManager(jmri.UserPreferencesManager) Test(org.junit.Test)

Example 14 with UserPreferencesManager

use of jmri.UserPreferencesManager in project JMRI by JMRI.

the class JmriUserPreferencesManagerTest method testGetMultipleChoiceList.

@Test
public void testGetMultipleChoiceList() {
    UserPreferencesManager m = new JmriUserPreferencesManager();
    m.setSaveAllowed(false);
    HashMap<Integer, String> options = new HashMap<>();
    options.put(1, "test1");
    Assert.assertTrue(m.getMultipleChoiceList(strClass).isEmpty());
    m.setMessageItemDetails(strClass, "item1", "description1", options, 0);
    Assert.assertEquals(1, m.getMultipleChoiceList(strClass).size());
    Assert.assertEquals("item1", m.getMultipleChoiceList(strClass).get(0));
}
Also used : HashMap(java.util.HashMap) UserPreferencesManager(jmri.UserPreferencesManager) Test(org.junit.Test)

Example 15 with UserPreferencesManager

use of jmri.UserPreferencesManager in project JMRI by JMRI.

the class JmriUserPreferencesManagerTest method testSetPreferenceState.

@Test
public void testSetPreferenceState() {
    UserPreferencesManager m = new TestJmriUserPreferencesManager();
    m.setSaveAllowed(false);
    Assert.assertFalse(m.getPreferenceState(strClass, "test1"));
    m.setPreferenceState(strClass, "test1", true);
    Assert.assertTrue(m.getPreferenceState(strClass, "test1"));
    Assert.assertFalse(m.getPreferenceState(strClass, "test2"));
    m.setPreferenceState(strClass, "test1", false);
    Assert.assertFalse(m.getPreferenceState(strClass, "test1"));
    Assert.assertFalse(m.getPreferenceState(strClass, "test2"));
    // non-existant class should not cause an error
    m.setPreferenceState("non.existant.class", "test1", true);
    JUnitAppender.assertWarnMessage("class name \"non.existant.class\" cannot be found, perhaps an expected plugin is missing?");
}
Also used : UserPreferencesManager(jmri.UserPreferencesManager) Test(org.junit.Test)

Aggregations

UserPreferencesManager (jmri.UserPreferencesManager)47 Test (org.junit.Test)43 HashMap (java.util.HashMap)10 Dimension (java.awt.Dimension)7 Point (java.awt.Point)5 AppConfigBase (apps.AppConfigBase)2 File (java.io.File)2 JLabel (javax.swing.JLabel)2 RosterGroupSelector (jmri.jmrit.roster.rostergroup.RosterGroupSelector)2 NullProfile (jmri.profile.NullProfile)2 BoxLayout (javax.swing.BoxLayout)1 JCheckBox (javax.swing.JCheckBox)1 JPanel (javax.swing.JPanel)1 ShutDownManager (jmri.ShutDownManager)1