Changeset 9611 in josm for trunk/test


Ignore:
Timestamp:
2016-01-24T15:06:37+01:00 (8 years ago)
Author:
Don-vip
Message:

update unit tests

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

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/mapmode/MapViewMock.java

    r8949 r9611  
    5252    @Override
    5353    public Point2D getPoint2D(EastNorth p) {
    54         return new Point2D.Double(p.getX(), p.getY());
     54        return p != null ? new Point2D.Double(p.getX(), p.getY()) : null;
    5555    }
    5656
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/ConflictDialogTest.java

    r9607 r9611  
    1212import org.openstreetmap.josm.JOSMFixture;
    1313import org.openstreetmap.josm.Main;
     14import org.openstreetmap.josm.data.coor.LatLon;
    1415import org.openstreetmap.josm.data.osm.Node;
    1516import org.openstreetmap.josm.data.osm.Relation;
     
    5455        ConflictPainter cp = new ConflictPainter(Main.map.mapView, new BufferedImage(800, 600, BufferedImage.TYPE_3BYTE_BGR).createGraphics());
    5556        Node n1 = new Node(1, 1);
     57        n1.setCoor(new LatLon(1, 1));
    5658        Node n2 = new Node(2, 1);
     59        n2.setCoor(new LatLon(2, 2));
    5760        Way w = new Way(1, 1);
    5861        w.addNode(n1);
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceTest.java

    r9585 r9611  
    22package org.openstreetmap.josm.gui.preferences.plugin;
    33
     4import static org.junit.Assert.assertEquals;
    45import static org.junit.Assert.assertNotNull;
     6
     7import java.io.File;
     8import java.util.Arrays;
     9import java.util.Collection;
     10import java.util.Collections;
    511
    612import org.junit.BeforeClass;
    713import org.junit.Test;
    814import org.openstreetmap.josm.JOSMFixture;
     15import org.openstreetmap.josm.TestUtils;
     16import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     17import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     18import org.openstreetmap.josm.plugins.PluginDownloadTask;
     19import org.openstreetmap.josm.plugins.PluginInformation;
    920
    1021/**
     
    2839        assertNotNull(new PluginPreference.Factory().createPreferenceSetting());
    2940    }
     41
     42    /**
     43     * Unit test of {@link PluginPreference#buildDownloadSummary}.
     44     * @throws Exception if an error occurs
     45     */
     46    @Test
     47    public void testBuildDownloadSummary() throws Exception  {
     48        final PluginInformation dummy = new PluginInformation(
     49                new File(TestUtils.getTestDataRoot() + "plugin/dummy_plugin.jar"), "dummy_plugin");
     50        assertEquals("", PluginPreference.buildDownloadSummary(
     51                new PluginDownloadTask(NullProgressMonitor.INSTANCE, Collections.<PluginInformation>emptyList(), "")));
     52        assertEquals("", PluginPreference.buildDownloadSummary(
     53                new PluginDownloadTask(NullProgressMonitor.INSTANCE, Arrays.asList(dummy), "")));
     54        assertEquals("The following plugin has been downloaded <strong>successfully</strong>:<ul><li>dummy_plugin (31772)</li></ul>"+
     55                     "Downloading the following plugin has <strong>failed</strong>:<ul><li>dummy_plugin</li></ul>",
     56                PluginPreference.buildDownloadSummary(
     57                        new PluginDownloadTask(NullProgressMonitor.INSTANCE, Arrays.asList(dummy), "") {
     58                    @Override
     59                    public Collection<PluginInformation> getFailedPlugins() {
     60                        return Collections.singleton(dummy);
     61                    }
     62
     63                    @Override
     64                    public Collection<PluginInformation> getDownloadedPlugins() {
     65                        return Collections.singleton(dummy);
     66                    }
     67                }));
     68    }
     69
     70    /**
     71     * Unit test of {@link PluginPreference#notifyDownloadResults}.
     72     */
     73    @Test
     74    public void testNotifyDownloadResults() {
     75        PluginDownloadTask task = new PluginDownloadTask(NullProgressMonitor.INSTANCE, Collections.<PluginInformation>emptyList(), "");
     76        PluginPreference.notifyDownloadResults(null, task, false);
     77        PluginPreference.notifyDownloadResults(null, task, true);
     78    }
     79
     80    /**
     81     * Unit test of {@link PluginPreference#addGui}.
     82     */
     83    @Test
     84    public void testAddGui() {
     85        new PluginPreference.Factory().createPreferenceSetting().addGui(new PreferenceTabbedPane());
     86    }
    3087}
Note: See TracChangeset for help on using the changeset viewer.