Ignore:
Timestamp:
2021-08-07T00:40:05+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #21203 - Use Object.toString() to display history combobox items (patch by marcello)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/widgets/HistoryComboBoxTest.java

    r18126 r18128  
    44import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
    55import static org.junit.jupiter.api.Assertions.assertEquals;
    6 import static org.junit.jupiter.api.Assertions.assertThrows;
    76
    87import java.util.stream.Stream;
     
    2221class HistoryComboBoxTest {
    2322    static Stream<Arguments> testNonRegression21203() {
    24         return Stream.of(Arguments.of("Hello world"), Arguments.of(new AutoCompletionItem("Hello world2")));
     23        return Stream.of(Arguments.of("Hello world"), Arguments.of(new AutoCompletionItem("Hello world2")), Arguments.of(new Double(42)));
    2524    }
    2625
     
    3938    }
    4039
    41     /**
    42      * This ensures that we do throw on unknown objects for #21203
    43      */
    4440    @Test
    45     void testNonRegression21203Throws() {
     41    void testEmptyEditor() {
    4642        final HistoryComboBox historyComboBox = new HistoryComboBox();
    47         // Sanity check
    48         assertEquals(0, historyComboBox.getModel().getSize());
    49         historyComboBox.getEditor().setItem(new Object());
    50         IllegalArgumentException illegalArgumentException = assertThrows(IllegalArgumentException.class,
    51                 historyComboBox::addCurrentItemToHistory);
    52         assertEquals("Object is not supported in addCurrentItemToHistory", illegalArgumentException.getMessage());
     43        assertDoesNotThrow(historyComboBox::addCurrentItemToHistory);
     44        historyComboBox.getEditor().setItem(null);
     45        assertDoesNotThrow(historyComboBox::addCurrentItemToHistory);
    5346    }
    5447}
Note: See TracChangeset for help on using the changeset viewer.