| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 2 | package org.openstreetmap.josm.actions;
|
|---|
| 3 |
|
|---|
| 4 | import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|---|
| 5 | import static org.junit.jupiter.api.Assertions.assertNull;
|
|---|
| 6 |
|
|---|
| 7 | import org.junit.jupiter.api.extension.RegisterExtension;
|
|---|
| 8 | import org.junit.jupiter.api.Test;
|
|---|
| 9 | import org.openstreetmap.josm.data.osm.DataSet;
|
|---|
| 10 | import org.openstreetmap.josm.gui.MainApplication;
|
|---|
| 11 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
|---|
| 12 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
|---|
| 13 |
|
|---|
| 14 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|---|
| 15 |
|
|---|
| 16 | /**
|
|---|
| 17 | * Unit tests for class {@link DeleteLayerAction}.
|
|---|
| 18 | */
|
|---|
| 19 | final class DeleteLayerActionTest {
|
|---|
| 20 |
|
|---|
| 21 | /**
|
|---|
| 22 | * Setup test.
|
|---|
| 23 | */
|
|---|
| 24 | @RegisterExtension
|
|---|
| 25 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
|---|
| 26 | static public JOSMTestRules test = new JOSMTestRules().main().projection();
|
|---|
| 27 |
|
|---|
| 28 | /**
|
|---|
| 29 | * Unit test of {@link DeleteLayerAction#actionPerformed}
|
|---|
| 30 | */
|
|---|
| 31 | @Test
|
|---|
| 32 | void testActionPerformed() {
|
|---|
| 33 | DeleteLayerAction action = new DeleteLayerAction();
|
|---|
| 34 | // No layer
|
|---|
| 35 | action.actionPerformed(null);
|
|---|
| 36 | // OsmDataLayer
|
|---|
| 37 | OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
|
|---|
| 38 | MainApplication.getLayerManager().addLayer(layer);
|
|---|
| 39 | assertNotNull(MainApplication.getLayerManager().getActiveLayer());
|
|---|
| 40 | action.actionPerformed(null);
|
|---|
| 41 | assertNull(MainApplication.getLayerManager().getActiveLayer());
|
|---|
| 42 | }
|
|---|
| 43 | }
|
|---|