Changeset 14149 in josm for trunk/test


Ignore:
Timestamp:
2018-08-12T17:24:32+02:00 (16 months ago)
Author:
Don-vip
Message:

see #15229 - deprecate Main.pref

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java

    r14143 r14149  
    1616import org.openstreetmap.josm.actions.DeleteAction;
    1717import org.openstreetmap.josm.command.DeleteCommand;
     18import org.openstreetmap.josm.data.Preferences;
    1819import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
    1920import org.openstreetmap.josm.data.preferences.JosmUrls;
     
    104105        System.setProperty("josm.home", josmHome);
    105106        TimeZone.setDefault(DateUtils.UTC);
    106         Config.setPreferencesInstance(Main.pref);
     107        Preferences pref = Preferences.main();
     108        Config.setPreferencesInstance(pref);
    107109        Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance());
    108110        Config.setUrlsProvider(JosmUrls.getInstance());
    109         Main.pref.resetToInitialState();
    110         Main.pref.enableSaveOnPut(false);
     111        pref.resetToInitialState();
     112        pref.enableSaveOnPut(false);
    111113        I18n.init();
    112114        // initialize the plaform hook, and
     
    115117
    116118        Logging.setLogLevel(Logging.LEVEL_INFO);
    117         Main.pref.init(false);
     119        pref.init(false);
    118120        String url = Config.getPref().get("osm-server.url");
    119121        if (url == null || url.isEmpty() || isProductionApiUrl(url)) {
  • trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/PluginDownloadTaskTest.java

    r14052 r14149  
    1313import org.junit.Rule;
    1414import org.junit.Test;
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.TestUtils;
     16import org.openstreetmap.josm.data.Preferences;
    1717import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1818import org.openstreetmap.josm.plugins.PluginDownloadTask;
     
    6262            new File(TestUtils.getTestDataRoot()), "__files/" + this.pluginPath
    6363        );
    64         final File pluginDir = Main.pref.getPluginsDirectory();
     64        final File pluginDir = Preferences.main().getPluginsDirectory();
    6565        final File pluginFile = new File(pluginDir, "dummy_plugin.jar");
    6666        final File pluginFileNew = new File(pluginDir, "dummy_plugin.jar.new");
     
    104104            new File(TestUtils.getTestDataRoot()), "__files/" + this.pluginPath
    105105        );
    106         final File pluginDir = Main.pref.getPluginsDirectory();
     106        final File pluginDir = Preferences.main().getPluginsDirectory();
    107107        final File pluginFile = new File(pluginDir, "corrupted_plugin.jar");
    108108        final File pluginFileNew = new File(pluginDir, "corrupted_plugin.jar.new");
  • trunk/test/unit/org/openstreetmap/josm/data/PreferencesTest.java

    r14138 r14149  
    66import org.junit.Rule;
    77import org.junit.Test;
    8 import org.openstreetmap.josm.Main;
    98import org.openstreetmap.josm.testutils.JOSMTestRules;
    109
     
    3332            "  <tag key='osm-server.url' value='http://fake.xxx/api'/>%n" +
    3433            "</preferences>%n", Version.getInstance().getVersion()),
    35                 Main.pref.toXML(true));
     34                Preferences.main().toXML(true));
    3635    }
    3736}
  • trunk/test/unit/org/openstreetmap/josm/data/preferences/NamedColorPropertyTest.java

    r12989 r14149  
    1111import org.junit.Rule;
    1212import org.junit.Test;
    13 import org.openstreetmap.josm.Main;
     13import org.openstreetmap.josm.data.Preferences;
    1414import org.openstreetmap.josm.spi.preferences.Config;
    1515import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    1818
    1919/**
    20  * Test {@link ColorProperty}
     20 * Test {@link NamedColorProperty}
    2121 * @author Michael Zangl
    2222 */
     
    3939
    4040    /**
    41      * Test {@link ColorProperty#get()}
     41     * Test {@link NamedColorProperty#get()}
    4242     */
    4343    @Test
     
    4747
    4848    /**
    49      * Test {@link ColorProperty#put}
     49     * Test {@link NamedColorProperty#put}
    5050     */
    5151    @Test
     
    6767    public void testColorAlpha() {
    6868        assertEquals(0x12, new NamedColorProperty("foo", new Color(0x12345678, true)).get().getAlpha());
    69         assertTrue(Main.pref.putList("clr.general.bar", Arrays.asList("#34567812", "general", "", "bar")));
     69        assertTrue(Preferences.main().putList("clr.general.bar", Arrays.asList("#34567812", "general", "", "bar")));
    7070        assertEquals(0x12, new NamedColorProperty("bar", Color.RED).get().getAlpha());
    7171    }
     
    8080
    8181    /**
    82      * Test {@link ColorProperty#getChildColor(String)}
     82     * Test {@link NamedColorProperty#getChildColor(String)}
    8383     */
    8484    @Test
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java

    r14138 r14149  
    2626import org.junit.Rule;
    2727import org.junit.Test;
    28 import org.openstreetmap.josm.Main;
    2928import org.openstreetmap.josm.TestUtils;
    3029import org.openstreetmap.josm.data.Bounds;
     
    217216        assertEquals(0xff00ff00, paintedSlippyMap.getRGB(0, 0));
    218217
    219         assertEquals("Green Tiles", Main.pref.get("slippy_map_chooser.mapstyle", "Fail"));
     218        assertEquals("Green Tiles", Config.getPref().get("slippy_map_chooser.mapstyle", "Fail"));
    220219    }
    221220
     
    244243        this.assertSingleSelectedSourceLabel("Magenta Tiles");
    245244
    246         assertEquals("Magenta Tiles", Main.pref.get("slippy_map_chooser.mapstyle", "Fail"));
     245        assertEquals("Magenta Tiles", Config.getPref().get("slippy_map_chooser.mapstyle", "Fail"));
    247246    }
    248247
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java

    r14081 r14149  
    66import org.junit.Rule;
    77import org.junit.Test;
    8 import org.openstreetmap.josm.Main;
    98import org.openstreetmap.josm.TestUtils;
     9import org.openstreetmap.josm.data.Preferences;
    1010import org.openstreetmap.josm.testutils.JOSMTestRules;
    1111import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
     
    3535            "All the preferences of this group are default, nothing to save", JOptionPane.OK_OPTION
    3636        ));
    37         new ExportProfileAction(Main.pref, "foo", "bar").actionPerformed(null);
    38         new ExportProfileAction(Main.pref, "expert", "expert").actionPerformed(null);
     37        new ExportProfileAction(Preferences.main(), "foo", "bar").actionPerformed(null);
     38        new ExportProfileAction(Preferences.main(), "expert", "expert").actionPerformed(null);
    3939    }
    4040}
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java

    r14138 r14149  
    2323import org.openstreetmap.josm.Main;
    2424import org.openstreetmap.josm.TestUtils;
     25import org.openstreetmap.josm.data.Preferences;
    2526import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    2627import org.openstreetmap.josm.gui.util.GuiHelper;
     
    9798        this.referenceBazJarOld = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v6.jar");
    9899        this.referenceBazJarNew = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v7.jar");
    99         this.pluginDir = Main.pref.getPluginsDirectory();
     100        this.pluginDir = Preferences.main().getPluginsDirectory();
    100101        this.targetDummyJar = new File(this.pluginDir, "dummy_plugin.jar");
    101102        this.targetDummyJarNew = new File(this.pluginDir, "dummy_plugin.jar.new");
  • trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java

    r14081 r14149  
    1717import org.openstreetmap.josm.Main;
    1818import org.openstreetmap.josm.TestUtils;
     19import org.openstreetmap.josm.data.Preferences;
    1920import org.openstreetmap.josm.spi.preferences.Config;
    2021import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    6667        this.referenceBazJarOld = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v6.jar");
    6768        this.referenceBazJarNew = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v7.jar");
    68         this.pluginDir = Main.pref.getPluginsDirectory();
     69        this.pluginDir = Preferences.main().getPluginsDirectory();
    6970        this.targetDummyJar = new File(this.pluginDir, "dummy_plugin.jar");
    7071        this.targetDummyJarNew = new File(this.pluginDir, "dummy_plugin.jar.new");
  • trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java

    r14138 r14149  
    1919import org.junit.Rule;
    2020import org.junit.Test;
    21 import org.openstreetmap.josm.Main;
     21import org.openstreetmap.josm.data.Preferences;
    2222import org.openstreetmap.josm.data.gpx.GpxData;
    2323import org.openstreetmap.josm.data.osm.DataSet;
     
    9393        // Download complete list of plugins
    9494        ReadRemotePluginInformationTask pluginInfoDownloadTask = new ReadRemotePluginInformationTask(
    95                 Main.pref.getOnlinePluginSites());
     95                Preferences.main().getOnlinePluginSites());
    9696        pluginInfoDownloadTask.run();
    9797        List<PluginInformation> plugins = pluginInfoDownloadTask.getAvailablePlugins();
  • trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java

    r14138 r14149  
    2626import org.openstreetmap.josm.actions.DeleteAction;
    2727import org.openstreetmap.josm.command.DeleteCommand;
     28import org.openstreetmap.josm.data.Preferences;
    2829import org.openstreetmap.josm.data.UserIdentityManager;
    2930import org.openstreetmap.josm.data.Version;
     
    418419        }
    419420
    420         Config.setPreferencesInstance(Main.pref);
     421        Preferences pref = Preferences.main();
     422        Config.setPreferencesInstance(pref);
    421423        Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance());
    422424        Config.setUrlsProvider(JosmUrls.getInstance());
     
    449451        if (usePreferences) {
    450452            @SuppressWarnings("unchecked")
    451             final Map<String, Setting<?>> defaultsMap = (Map<String, Setting<?>>) TestUtils.getPrivateField(Main.pref, "defaultsMap");
     453            final Map<String, Setting<?>> defaultsMap = (Map<String, Setting<?>>) TestUtils.getPrivateField(pref, "defaultsMap");
    452454            defaultsMap.clear();
    453             Main.pref.resetToInitialState();
    454             Main.pref.enableSaveOnPut(false);
     455            pref.resetToInitialState();
     456            pref.enableSaveOnPut(false);
    455457            // No pref init -> that would only create the preferences file.
    456458            // We force the use of a wrong API server, just in case anyone attempts an upload
     
    543545        MemoryManagerTest.resetState(true);
    544546        cleanLayerEnvironment();
    545         Main.pref.resetToInitialState();
     547        Preferences.main().resetToInitialState();
    546548        System.gc();
    547549    }
     
    584586        // TODO: Remove global listeners and other global state.
    585587        ProjectionRegistry.clearProjectionChangeListeners();
    586         Main.pref.resetToInitialState();
     588        Preferences.main().resetToInitialState();
    587589
    588590        if (this.assumeRevisionString != null && this.originalVersion != null) {
Note: See TracChangeset for help on using the changeset viewer.