Search in sources :

Example 31 with UserPreferencesManager

use of jmri.UserPreferencesManager in project JMRI by JMRI.

the class JmriUserPreferencesManagerTest method testGetMultipleChoiceSize.

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

Example 32 with UserPreferencesManager

use of jmri.UserPreferencesManager in project JMRI by JMRI.

the class JmriUserPreferencesManagerTest method testSetWindowLocation.

@Test
public void testSetWindowLocation() {
    UserPreferencesManager m = new JmriUserPreferencesManager();
    m.setSaveAllowed(false);
    Point windowLocation = new Point(69, 96);
    m.setWindowLocation(strClass, windowLocation);
    Point savedWindowLocation = m.getWindowLocation(strClass);
    Assert.assertEquals(windowLocation, savedWindowLocation);
}
Also used : Point(java.awt.Point) UserPreferencesManager(jmri.UserPreferencesManager) Test(org.junit.Test)

Example 33 with UserPreferencesManager

use of jmri.UserPreferencesManager in project JMRI by JMRI.

the class JmriUserPreferencesManagerTest method testGetSimplePreferenceStateList.

@Test
public void testGetSimplePreferenceStateList() {
    UserPreferencesManager m = new JmriUserPreferencesManager();
    m.setSaveAllowed(false);
    // defaults to empty
    Assert.assertEquals(0, m.getSimplePreferenceStateList().size());
    m.setSimplePreferenceState("test1", true);
    // setting a preference to true adds it
    Assert.assertEquals(1, m.getSimplePreferenceStateList().size());
    m.setSimplePreferenceState("test1", false);
    // setting a preference to false removes it
    Assert.assertEquals(0, m.getSimplePreferenceStateList().size());
    m.setSimplePreferenceState("test1", true);
    m.setSimplePreferenceState("test2", true);
    // setting a preference to true adds it
    Assert.assertEquals(2, m.getSimplePreferenceStateList().size());
    m.setSimplePreferenceState("test2", true);
    // setting a preference to true twice adds it once
    Assert.assertEquals(2, m.getSimplePreferenceStateList().size());
}
Also used : UserPreferencesManager(jmri.UserPreferencesManager) Test(org.junit.Test)

Example 34 with UserPreferencesManager

use of jmri.UserPreferencesManager in project JMRI by JMRI.

the class JmriUserPreferencesManagerTest method testDisallowSave.

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

Example 35 with UserPreferencesManager

use of jmri.UserPreferencesManager in project JMRI by JMRI.

the class JmriUserPreferencesManagerTest method testGetSaveWindowLocation.

@Test
public void testGetSaveWindowLocation() {
    UserPreferencesManager m = new JmriUserPreferencesManager();
    m.setSaveAllowed(false);
    Assert.assertFalse(m.getSaveWindowLocation(strClass));
    m.setSaveWindowLocation(strClass, true);
    Assert.assertTrue(m.getSaveWindowLocation(strClass));
    m.setSaveWindowLocation(strClass, false);
    Assert.assertFalse(m.getSaveWindowLocation(strClass));
}
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