Changeset 18008 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2021-07-12T23:45:16+02:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/layer/GpxLayerTest.java
r17845 r18008 2 2 package org.openstreetmap.josm.gui.layer; 3 3 4 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 import static org.junit.jupiter.api.Assertions.assertFalse; 6 7 import static org.junit.jupiter.api.Assertions.assertNull; 8 import static org.junit.jupiter.api.Assertions.assertThrows; 7 9 import static org.junit.jupiter.api.Assertions.assertTrue; 8 import static org.junit.jupiter.api.Assertions.assertThrows;9 10 10 11 import java.awt.Color; 12 import java.awt.Component; 11 13 import java.io.IOException; 12 14 import java.util.ArrayList; … … 27 29 import org.openstreetmap.josm.data.gpx.WayPoint; 28 30 import org.openstreetmap.josm.data.osm.DataSet; 31 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 32 import org.openstreetmap.josm.data.projection.CustomProjection; 29 33 import org.openstreetmap.josm.data.projection.Projections; 30 34 import org.openstreetmap.josm.gui.MainApplication; … … 261 265 assertNull(new GpxLayer(new GpxData(), "", false).getChangesetSourceTag()); 262 266 } 267 268 /** 269 * Checks that potential operations that could be called after destroy() are harmless 270 */ 271 @Test 272 void testRobustnessAfterDestroy() { 273 GpxData data = new GpxData(); 274 GpxLayer layer = new GpxLayer(data, "1", false); 275 GpxLayer otherLayer = new GpxLayer(new GpxData(), "2", false); 276 assertEquals(data, layer.getData()); 277 assertTrue(layer.isMergable(otherLayer)); 278 assertTrue(layer.hasColor()); 279 assertTrue(layer.isSavable()); 280 assertTrue(layer.checkSaveConditions()); 281 assertFalse(layer.isModified()); 282 assertFalse(layer.requiresSaveToFile()); 283 assertNull(layer.getChangesetSourceTag()); 284 assertNull(layer.getAssociatedFile()); 285 286 layer.destroy(); 287 288 assertNull(layer.getData()); 289 assertNull(layer.getColor()); 290 assertFalse(layer.hasColor()); 291 assertFalse(layer.isMergable(otherLayer)); 292 assertFalse(layer.isSavable()); 293 assertFalse(layer.checkSaveConditions()); 294 assertFalse(layer.isModified()); 295 assertFalse(layer.requiresSaveToFile()); 296 assertNull(layer.getChangesetSourceTag()); 297 assertNull(layer.getAssociatedFile()); 298 Object infoComponent = layer.getInfoComponent(); 299 assertTrue(infoComponent instanceof JScrollPane); 300 Component view = ((JScrollPane) infoComponent).getViewport().getView(); 301 assertTrue(view instanceof HtmlPanel); 302 String text = ((HtmlPanel) view).getEditorPane().getText().trim(); 303 assertTrue(text.startsWith("<html>"), text); 304 assertTrue(text.endsWith("</html>"), text); 305 assertEquals("<html><br></html>", layer.getToolTipText()); 306 assertDoesNotThrow(() -> layer.jumpToNextMarker()); 307 assertDoesNotThrow(() -> layer.jumpToPreviousMarker()); 308 assertDoesNotThrow(() -> layer.visitBoundingBox(new BoundingXYVisitor())); 309 assertDoesNotThrow(() -> layer.filterTracksByDate(null, null, false)); 310 assertDoesNotThrow(() -> layer.projectionChanged(new CustomProjection(), new CustomProjection())); 311 } 263 312 }
Note:
See TracChangeset
for help on using the changeset viewer.