Changeset 18783 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2023-07-26T22:06:14+02:00 (16 months ago)
Author:
taylor.smock
Message:

Fix #23081: NoSuchElementException in ConflictDialog.ResolveToAction#actionPerformed

This occurs when one of the Resolve to (my|their) versions actions is called
when no conflict is selected.

There are two distinct bugs:

  • isConflictSelected did not check to make certain that the selection index made sense
  • ResolveActions were not enabled/disabled when the popup menu became visible, depending upon whether the current selection was valid
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/ConflictDialogTest.java

    r17275 r18783  
    22package org.openstreetmap.josm.gui.dialogs;
    33
     4import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
    45import static org.junit.jupiter.api.Assertions.assertEquals;
    5 import static org.junit.jupiter.api.Assertions.assertNotNull;
    66
    77import java.awt.Color;
    88import java.awt.image.BufferedImage;
    99
    10 import org.junit.jupiter.api.extension.RegisterExtension;
    1110import org.junit.jupiter.api.Test;
    1211import org.openstreetmap.josm.data.coor.LatLon;
     
    1918import org.openstreetmap.josm.gui.dialogs.ConflictDialog.ConflictPainter;
    2019import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
    22 
    23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     20import org.openstreetmap.josm.testutils.annotations.Main;
     21import org.openstreetmap.josm.testutils.annotations.Projection;
    2422
    2523/**
    2624 * Unit tests of {@link ConflictDialog} class.
    2725 */
     26@Main
     27@Projection
    2828class ConflictDialogTest {
    29 
    30     /**
    31      * Setup tests
    32      */
    33     @RegisterExtension
    34     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    35     public JOSMTestRules test = new JOSMTestRules().main().projection();
    36 
    3729    /**
    3830     * Unit test of {@link ConflictDialog#ConflictDialog}.
     
    4032    @Test
    4133    void testConflictDialog() {
    42         assertNotNull(new ConflictDialog());
     34        assertDoesNotThrow(ConflictDialog::new);
    4335    }
    4436
Note: See TracChangeset for help on using the changeset viewer.