Ticket #13432: patch-test-data-layer-is-changed.patch

File patch-test-data-layer-is-changed.patch, 2.6 KB (added by michael2402, 6 years ago)
  • new file test/unit/org/openstreetmap/josm/gui/layer/AbstractMapViewPaintableTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/AbstractMapViewPaintableTest.java b/test/unit/org/openstreetmap/josm/gui/layer/AbstractMapViewPaintableTest.java
    new file mode 100644
    index 0000000..85373c8
    - +  
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.gui.layer;
     3
     4import static org.junit.Assert.assertFalse;
     5import static org.junit.Assert.assertTrue;
     6
     7import java.util.concurrent.atomic.AtomicBoolean;
     8
     9import org.junit.Before;
     10import org.junit.Rule;
     11import org.junit.Test;
     12import org.openstreetmap.josm.gui.layer.MapViewPaintable.PaintableInvalidationListener;
     13import org.openstreetmap.josm.testutils.JOSMTestRules;
     14
     15import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     16
     17/**
     18 * Test of the base {@link AbstractMapViewPaintable} class
     19 * @author Michael Zangl
     20 * @since xxx
     21 */
     22public class AbstractMapViewPaintableTest {
     23    /**
     24     * No special test rules
     25     */
     26    @Rule
     27    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     28    public JOSMTestRules test = new JOSMTestRules();
     29
     30    private Layer testLayer;
     31
     32    /**
     33     * Create test layer
     34     */
     35    @Before
     36    public void setUp() {
     37        testLayer = new LayerManagerTest.TestLayer();
     38    }
     39
     40    /**
     41     * Test {@link Layer#invalidate()}
     42     */
     43    @Test
     44    public void testInvalidate() {
     45        AtomicBoolean fired = new AtomicBoolean();
     46        PaintableInvalidationListener listener = l -> fired.set(true);
     47        testLayer.addInvalidationListener(listener);
     48        assertFalse(fired.get());
     49        testLayer.invalidate();
     50        assertTrue(fired.get());
     51
     52        fired.set(false);
     53        testLayer.removeInvalidationListener(listener);
     54        testLayer.invalidate();
     55        assertFalse(fired.get());
     56    }
     57
     58}
  • test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java
    index 3311a9a..e470793 100644
    a b public class OsmDataLayerTest { 
    219219    }
    220220
    221221    /**
    222      * Unit test of {@link OsmDataLayer#isChanged}.
    223      */
    224     @Test
    225     public void testIsChanged() {
    226         DataSet ds = new DataSet();
    227         OsmDataLayer layer = new OsmDataLayer(ds, "", null);
    228         assertTrue(layer.isChanged());
    229     }
    230 
    231     /**
    232222     * Unit test of {@link OsmDataLayer#isModified}.
    233223     */
    234224    @Test