Ignore:
Timestamp:
2023-03-08T20:00:36+01:00 (20 months ago)
Author:
taylor.smock
Message:

See #22767, fix failing unit tests

The fix for #22767 included a new unit test, which caused a cascading failure.
The first step of the fix included removing the destroyed dialog from the
MapFrame. Unfortunately, MapFrame#removeToggleDialog did not properly
remove the ToggleDialog -- it called DialogsPanel#remove(Component) with
the ToggleDialog as an argument. Since the DialogsPanel never adds the
ToggleDialog as a direct subcomponent, this was effectively a no-op.

Location:
trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialogTest.java

    r18685 r18686  
    2121import javax.swing.JPanel;
    2222
     23import org.junit.jupiter.api.AfterEach;
    2324import org.junit.jupiter.api.BeforeEach;
    2425import org.junit.jupiter.api.extension.RegisterExtension;
     
    4445
    4546    private ImageViewerDialog dialog;
     47
    4648    @BeforeEach
    4749    void setup() {
    4850        this.dialog = ImageViewerDialog.getInstance();
    4951        this.dialog.displayImages(null);
     52    }
     53
     54    @AfterEach
     55    void tearDown() {
     56        this.dialog.destroy();
    5057    }
    5158
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoaderTest.java

    r18035 r18686  
    1010import java.util.List;
    1111
     12import org.junit.jupiter.api.AfterEach;
    1213import org.junit.jupiter.api.Test;
    13 import org.junit.jupiter.api.extension.RegisterExtension;
    1414import org.openstreetmap.josm.TestUtils;
    1515import org.openstreetmap.josm.gui.MainApplication;
    1616import org.openstreetmap.josm.gui.layer.GpxLayer;
    1717import org.openstreetmap.josm.io.GpxReader;
    18 import org.openstreetmap.josm.testutils.JOSMTestRules;
    19 
    20 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     18import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2119
    2220/**
    2321 * Unit tests of {@link ImagesLoader} class.
    2422 */
     23@BasicPreferences
    2524class ImagesLoaderTest {
    2625
    27     /**
    28      * We need prefs for this.
    29      */
    30     @RegisterExtension
    31     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    32     public JOSMTestRules test = new JOSMTestRules().preferences();
     26    @AfterEach
     27    void tearDown() {
     28        if (ImageViewerDialog.hasInstance()) {
     29            ImageViewerDialog.getInstance().destroy();
     30        }
     31    }
    3332
    3433    /**
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/WikimediaCommonsLoaderTest.java

    r18050 r18686  
    1111import java.util.List;
    1212
     13import org.junit.jupiter.api.AfterEach;
    1314import org.junit.jupiter.api.BeforeAll;
    1415import org.junit.jupiter.api.Test;
     
    2930    static void beforeAll() {
    3031        HttpClient.setFactory(Http1Client::new);
     32    }
     33
     34    @AfterEach
     35    void tearDown() {
     36        if (ImageViewerDialog.hasInstance()) {
     37            ImageViewerDialog.getInstance().destroy();
     38        }
    3139    }
    3240
Note: See TracChangeset for help on using the changeset viewer.