Changeset 8914 in josm


Ignore:
Timestamp:
2015-10-19T23:49:11+02:00 (9 years ago)
Author:
Don-vip
Message:

improve unit tests

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/conflict/ConflictAddCommand.java

    r8910 r8914  
    6161    @Override
    6262    public void undoCommand() {
    63         if (Main.map != null && !Main.map.mapView.hasLayer(getLayer())) {
     63        if (Main.isDisplayingMapView() && !Main.map.mapView.hasLayer(getLayer())) {
    6464            Main.warn(tr("Layer ''{0}'' does not exist any more. Cannot remove conflict for object ''{1}''.",
    6565                    getLayer().getName(),
  • trunk/src/org/openstreetmap/josm/command/conflict/ConflictResolveCommand.java

    r8910 r8914  
    6868        super.undoCommand();
    6969
    70         if (!Main.map.mapView.hasLayer(getLayer())) {
    71             Main.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more",
    72                     this.toString(),
    73                     getLayer().toString()
    74             ));
    75             return;
     70        if (Main.isDisplayingMapView()) {
     71            if (!Main.map.mapView.hasLayer(getLayer())) {
     72                Main.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more",
     73                        this.toString(),
     74                        getLayer().toString()
     75                ));
     76                return;
     77            }
     78
     79            Main.map.mapView.setActiveLayer(getLayer());
    7680        }
    77 
    78         Main.map.mapView.setActiveLayer(getLayer());
    7981        reconstituteConflicts();
    8082    }
  • trunk/test/unit/org/openstreetmap/josm/command/conflict/ConflictAddCommandTest.java

    r8910 r8914  
    33
    44import static org.junit.Assert.assertFalse;
     5import static org.junit.Assert.assertNotNull;
    56import static org.junit.Assert.assertTrue;
    67
     8import org.junit.BeforeClass;
    79import org.junit.Test;
     10import org.openstreetmap.josm.JOSMFixture;
    811import org.openstreetmap.josm.data.conflict.Conflict;
    912import org.openstreetmap.josm.data.osm.DataSet;
     13import org.openstreetmap.josm.data.osm.Node;
    1014import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1115import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    1519 */
    1620public class ConflictAddCommandTest {
     21
     22    /**
     23     * Setup test.
     24     */
     25    @BeforeClass
     26    public static void setUpBeforeClass() {
     27        JOSMFixture.createUnitTestFixture().init();
     28    }
    1729
    1830    /**
     
    3143        assertTrue(layer.getConflicts().isEmpty());
    3244    }
     45
     46    /**
     47     * Unit test of {@code ConflictAddCommand#getDescriptionIcon} method.
     48     */
     49    @Test
     50    public void testGetDescriptionIcon() {
     51        OsmDataLayer layer = new OsmDataLayer(new DataSet(), null, null);
     52        Conflict<Node> conflict = new Conflict<>(new Node(), new Node());
     53        assertNotNull(new ConflictAddCommand(layer, conflict).getDescriptionIcon());
     54    }
    3355}
Note: See TracChangeset for help on using the changeset viewer.