Changeset 18895 in josm for trunk/test/unit/org
- Timestamp:
- 2023-11-07T14:21:38+01:00 (13 months ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/gui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/layer/DeleteLayerActionTest.java
r18839 r18895 11 11 import static org.junit.jupiter.api.Assertions.assertTrue; 12 12 13 import java.util.Collections; 13 14 import java.util.Objects; 14 15 import java.util.concurrent.atomic.AtomicInteger; … … 22 23 import org.openstreetmap.josm.gui.layer.Layer; 23 24 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 25 import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer; 24 26 import org.openstreetmap.josm.testutils.annotations.Main; 25 27 import org.openstreetmap.josm.testutils.annotations.Projection; … … 123 125 } 124 126 127 @Test 128 void testRemoveBottomActiveWithBackgroundLayer() { 129 GeoImageLayer geoImageLayer = new GeoImageLayer(Collections.emptyList(), null, "imageLayer"); 130 OsmDataLayer osmDataLayer1 = new OsmDataLayer(new DataSet(), "dataLayer1", null); 131 OsmDataLayer osmDataLayer2 = new OsmDataLayer(new DataSet(), "dataLayer2", null); 132 133 // remove all the layers added in BeforeEach() 134 for (Layer l : MainApplication.getLayerManager().getLayers()) { 135 MainApplication.getLayerManager().removeLayer(l); 136 } 137 MainApplication.getLayerManager().addLayer(geoImageLayer); 138 MainApplication.getLayerManager().addLayer(osmDataLayer1); 139 MainApplication.getLayerManager().addLayer(osmDataLayer2); 140 141 model.getLayerManager().setActiveLayer(osmDataLayer1); 142 model.setSelectedLayer(osmDataLayer1); 143 144 deleteLayerAction.actionPerformed(null); 145 146 assertSame(model.getLayerManager().getActiveLayer(), model.getLayer(0)); 147 assertEquals("dataLayer2", Objects.requireNonNull(model.getLayerManager().getActiveLayer().getName())); 148 assertAll(model.getLayers().stream().map(layer -> () -> assertNotSame(osmDataLayer1, layer))); 149 } 150 151 @Test 152 void testRemoveBottomActiveAllHidden() { 153 hideRange(0, 9); 154 final Layer toRemove = model.getLayer(9); 155 assertNotNull(toRemove); 156 assertFalse(toRemove.isVisible()); 157 assertEquals(0, model.getLayers().stream().filter(Layer::isVisible).count()); 158 159 model.getLayerManager().setActiveLayer(toRemove); 160 model.setSelectedLayer(toRemove); 161 deleteLayerAction.actionPerformed(null); 162 163 assertSame(model.getLayerManager().getActiveLayer(), model.getLayer(8)); 164 assertEquals("testActiveLayer1", Objects.requireNonNull(model.getLayer(8)).getName()); 165 assertAll(model.getLayers().stream().map(layer -> () -> assertNotSame(toRemove, layer))); 166 } 167 125 168 private void hideRange(int start, int end) { 126 169 model.getSelectionModel().setSelectionInterval(start, end); -
trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayerTest.java
r18870 r18895 6 6 import java.util.Collections; 7 7 8 import org.junit.jupiter.api.AfterEach; 8 9 import org.junit.jupiter.api.Test; 9 10 import org.openstreetmap.josm.data.osm.DataSet; … … 19 20 @Main 20 21 class GeoImageLayerTest { 22 @AfterEach 23 void tearDown() { 24 if (ImageViewerDialog.hasInstance()) { 25 ImageViewerDialog.getInstance().destroy(); 26 } 27 } 28 21 29 /** 22 30 * Test that {@link GeoImageLayer#mergeFrom} throws IAE for invalid arguments -
trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoaderTest.java
r18870 r18895 16 16 import org.openstreetmap.josm.io.GpxReader; 17 17 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 18 import org.openstreetmap.josm.testutils.annotations.Main; 19 import org.openstreetmap.josm.testutils.annotations.Projection; 18 20 19 21 /** … … 21 23 */ 22 24 @BasicPreferences 25 @Main 26 @Projection 23 27 class ImagesLoaderTest { 24 28 /** -
trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/WikimediaCommonsLoaderTest.java
r18689 r18895 11 11 import java.util.List; 12 12 13 import org.junit.jupiter.api. BeforeAll;13 import org.junit.jupiter.api.AfterEach; 14 14 import org.junit.jupiter.api.Test; 15 15 import org.openstreetmap.josm.data.Bounds; 16 16 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 17 import org.openstreetmap.josm.t ools.Http1Client;18 import org.openstreetmap.josm.t ools.HttpClient;17 import org.openstreetmap.josm.testutils.annotations.HTTP; 18 import org.openstreetmap.josm.testutils.annotations.Main; 19 19 20 20 import com.github.tomakehurst.wiremock.WireMockServer; … … 24 24 */ 25 25 @BasicPreferences 26 @HTTP 27 @Main 26 28 class WikimediaCommonsLoaderTest { 27 28 @BeforeAll 29 static void beforeAll() { 30 HttpClient.setFactory(Http1Client::new); 29 @AfterEach 30 void tearDown() { 31 if (ImageViewerDialog.hasInstance()) { 32 ImageViewerDialog.getInstance().destroy(); 33 } 31 34 } 32 35 -
trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarkerTest.java
r18870 r18895 8 8 import java.net.MalformedURLException; 9 9 10 import org.junit.jupiter.api.AfterEach; 10 11 import org.junit.jupiter.api.Test; 11 12 import org.openstreetmap.josm.TestUtils; … … 13 14 import org.openstreetmap.josm.data.gpx.GpxData; 14 15 import org.openstreetmap.josm.data.gpx.WayPoint; 16 import org.openstreetmap.josm.gui.layer.geoimage.ImageViewerDialog; 15 17 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 16 18 import org.openstreetmap.josm.testutils.annotations.Main; … … 22 24 @Main 23 25 class ImageMarkerTest { 26 @AfterEach 27 void tearDown() { 28 if (ImageViewerDialog.hasInstance()) { 29 ImageViewerDialog.getInstance().destroy(); 30 } 31 } 32 24 33 /** 25 34 * Unit test of {@link ImageMarker#ImageMarker}.
Note:
See TracChangeset
for help on using the changeset viewer.