Changeset 19289 in josm for trunk/test
- Timestamp:
- 2025-01-24T14:05:46+01:00 (3 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java
r19155 r19289 8 8 import static org.junit.jupiter.api.Assertions.assertTrue; 9 9 10 import java.util.Arrays; 10 11 import java.util.List; 11 12 … … 13 14 import org.junit.jupiter.api.Test; 14 15 import org.openstreetmap.gui.jmapviewer.FeatureAdapter; 16 import org.openstreetmap.josm.data.Bounds; 15 17 import org.openstreetmap.josm.data.imagery.ImageryInfo; 18 import org.openstreetmap.josm.data.osm.DataSet; 19 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 16 20 import org.openstreetmap.josm.gui.MainApplication; 21 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 17 22 import org.openstreetmap.josm.gui.layer.TMSLayer; 18 23 import org.openstreetmap.josm.gui.layer.WMSLayer; 24 import org.openstreetmap.josm.gui.util.GuiHelper; 19 25 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 20 26 import org.openstreetmap.josm.testutils.annotations.BasicWiremock; 27 import org.openstreetmap.josm.testutils.annotations.Main; 21 28 import org.openstreetmap.josm.testutils.annotations.OsmApi; 22 29 import org.openstreetmap.josm.testutils.annotations.Projection; … … 99 106 assertTrue(MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).isEmpty()); 100 107 } 108 109 110 /** 111 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/24097">#24097</a>: Zoom to imagery layer 112 * This tests two things: 113 * <ul> 114 * <li>Imagery layer zoom to action works properly</li> 115 * <li>Imagery layer bounds is not zoomed to on layer add</li> 116 * </ul> 117 */ 118 @Main 119 @Test 120 void testNonRegression24097() { 121 // First, add a new data layer 122 MainApplication.getLayerManager().addLayer(new OsmDataLayer(new DataSet(), 123 "AddImageryLayerActionTest#testNonRegression24097", null)); 124 // Now zoom to a random area 125 MainApplication.getMap().mapView.zoomTo(new Bounds(39.0665807, -108.5212326, 39.0793079, -108.4986591)); 126 // Initialize the zoom actions 127 MainApplication.getMenu().initialize(); 128 final Bounds startingBounds = MainApplication.getMap().mapView.getRealBounds(); 129 ImageryInfo testInfo = new ImageryInfo("Test", "https://127.0.0.1/{zoom}/{x}/{y}.png", "tms", null, null, "Test"); 130 testInfo.setBounds(new ImageryInfo.ImageryBounds("-0.001,-0.001,0.001,0.001", ",")); 131 new AddImageryLayerAction(testInfo).actionPerformed(null); 132 GuiHelper.runInEDTAndWait(() -> { /* Sync GUI thread */ }); 133 // There is a bit of zooming done during the load of the imagery 134 assertTrue(startingBounds.toBBox().bboxIsFunctionallyEqual(MainApplication.getMap().mapView.getRealBounds().toBBox(), 0.001), 135 "Adding an imagery layer should not zoom to the imagery layer bounds"); 136 assertEquals(1, MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).size()); 137 final TMSLayer tmsLayer = MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).get(0); 138 final AutoScaleAction autoScaleAction = Arrays.stream(tmsLayer.getMenuEntries()).filter(AutoScaleAction.class::isInstance) 139 .map(AutoScaleAction.class::cast).findFirst().orElseThrow(); 140 autoScaleAction.actionPerformed(null); 141 // We can't check the bbox here, since the mapView doesn't have any actual width/height. 142 // So we just check the center. 143 assertTrue(new Bounds(-0.001, -0.001, 0.001, 0.001) 144 .contains(ProjectionRegistry.getProjection().eastNorth2latlon( 145 MainApplication.getMap().mapView.getCenter())), 146 "The action should have zoomed to the bbox for the imagery layer"); 147 } 101 148 }
Note:
See TracChangeset
for help on using the changeset viewer.