Changeset 14052 in josm for trunk/test/unit/org/openstreetmap/josm/gui/preferences
- Timestamp:
- 2018-07-26T22:01:31+02:00 (6 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/gui/preferences
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java
r10378 r14052 2 2 package org.openstreetmap.josm.gui.preferences.advanced; 3 3 4 import org.junit.BeforeClass; 4 import javax.swing.JOptionPane; 5 6 import org.junit.Rule; 5 7 import org.junit.Test; 6 import org.openstreetmap.josm.JOSMFixture;7 8 import org.openstreetmap.josm.Main; 9 import org.openstreetmap.josm.testutils.JOSMTestRules; 10 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 11 12 import com.google.common.collect.ImmutableMap; 13 14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 8 15 9 16 /** … … 11 18 */ 12 19 public class ExportProfileActionTest { 13 14 20 /** 15 * Setup test .21 * Setup tests 16 22 */ 17 @BeforeClass 18 public static void setUpBeforeClass() { 19 JOSMFixture.createUnitTestFixture().init(); 20 } 23 @Rule 24 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 25 public JOSMTestRules test = new JOSMTestRules().preferences().assertionsInEDT(); 21 26 22 27 /** … … 25 30 @Test 26 31 public void testAction() { 32 new JOptionPaneSimpleMocker(ImmutableMap.of( 33 "All the preferences of this group are default, nothing to save", JOptionPane.OK_OPTION 34 )); 27 35 new ExportProfileAction(Main.pref, "foo", "bar").actionPerformed(null); 28 36 new ExportProfileAction(Main.pref, "expert", "expert").actionPerformed(null); -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTableTest.java
r12884 r14052 9 9 import java.util.Arrays; 10 10 11 import org.junit.BeforeClass; 11 import javax.swing.JOptionPane; 12 13 import org.junit.Rule; 12 14 import org.junit.Test; 13 import org.openstreetmap.josm.JOSMFixture; 15 import org.openstreetmap.josm.gui.ExtendedDialog; 16 import org.openstreetmap.josm.gui.preferences.advanced.PreferencesTable.AllSettingsTableModel; 14 17 import org.openstreetmap.josm.spi.preferences.StringSetting; 15 import org.openstreetmap.josm.gui.preferences.advanced.PreferencesTable.AllSettingsTableModel; 18 import org.openstreetmap.josm.testutils.JOSMTestRules; 19 import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; 20 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 21 22 import com.google.common.collect.ImmutableMap; 23 24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 16 25 17 26 /** … … 19 28 */ 20 29 public class PreferencesTableTest { 21 22 30 /** 23 * Setup test .31 * Setup tests 24 32 */ 25 @BeforeClass 26 public static void setUpBeforeClass() { 27 JOSMFixture.createUnitTestFixture().init(); 28 } 33 @Rule 34 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 35 public JOSMTestRules test = new JOSMTestRules().preferences().assertionsInEDT(); 29 36 30 37 private static PrefEntry newPrefEntry(String value) { … … 43 50 @Test 44 51 public void testPreferencesTable() { 52 new JOptionPaneSimpleMocker(ImmutableMap.of( 53 "Please select the row to edit.", JOptionPane.OK_OPTION, 54 "Please select the row to delete.", JOptionPane.OK_OPTION 55 )); 56 new ExtendedDialogMocker() { 57 @Override 58 protected int getMockResult(final ExtendedDialog instance) { 59 if (instance.getTitle().equals("Add setting")) { 60 return 1 + this.getButtonPositionFromLabel(instance, "Cancel"); 61 } else { 62 return super.getMockResult(instance); 63 } 64 } 65 }; 45 66 PreferencesTable t = newTable(); 46 67 t.fireDataChanged(); -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceTest.java
r11974 r14052 10 10 import java.util.Collections; 11 11 12 import org.junit. BeforeClass;12 import org.junit.Rule; 13 13 import org.junit.Test; 14 import org.openstreetmap.josm.JOSMFixture;15 14 import org.openstreetmap.josm.TestUtils; 16 15 import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; … … 19 18 import org.openstreetmap.josm.plugins.PluginException; 20 19 import org.openstreetmap.josm.plugins.PluginInformation; 20 import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker; 21 import org.openstreetmap.josm.testutils.JOSMTestRules; 22 23 import com.google.common.collect.ImmutableMap; 24 25 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 21 26 22 27 /** … … 24 29 */ 25 30 public class PluginPreferenceTest { 26 27 31 /** 28 32 * Setup test. 29 33 */ 30 @BeforeClass 31 public static void setUpBeforeClass() { 32 JOSMFixture.createUnitTestFixture().init(); 33 } 34 @Rule 35 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 36 public JOSMTestRules test = new JOSMTestRules().preferences().assertionsInEDT().platform(); 34 37 35 38 /** … … 48 51 public static PluginInformation getDummyPluginInformation() throws PluginException { 49 52 return new PluginInformation( 50 new File(TestUtils.getTestDataRoot() + " plugin/dummy_plugin.jar"), "dummy_plugin");53 new File(TestUtils.getTestDataRoot() + "__files/plugin/dummy_plugin.v31772.jar"), "dummy_plugin"); 51 54 } 52 55 … … 89 92 @Test 90 93 public void testNotifyDownloadResults() { 94 new HelpAwareOptionPaneMocker(ImmutableMap.<String, Object>builder() 95 .put("<html></html>", "OK") // (buildDownloadSummary() output was empty) 96 .put("<html>Please restart JOSM to activate the downloaded plugins.</html>", "OK") 97 .build() 98 ); 99 91 100 PluginDownloadTask task = new PluginDownloadTask(NullProgressMonitor.INSTANCE, Collections.<PluginInformation>emptyList(), ""); 92 101 PluginPreference.notifyDownloadResults(null, task, false);
Note:
See TracChangeset
for help on using the changeset viewer.