Changeset 14385 in josm


Ignore:
Timestamp:
2018-10-30T00:47:23+01:00 (6 months ago)
Author:
Don-vip
Message:

fix #16914 - GenericRelationEditorTest: fix for non-headless mode (patch by ris)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

    r14153 r14385  
    88import java.awt.Dimension;
    99import java.awt.FlowLayout;
    10 import java.awt.GraphicsEnvironment;
    1110import java.awt.GridBagConstraints;
    1211import java.awt.GridBagLayout;
     
    906905            for (OsmPrimitive p : primitivesToAdd) {
    907906                if (p instanceof Relation && orig.equals(p)) {
    908                     if (!GraphicsEnvironment.isHeadless()) {
    909                         warnOfCircularReferences(p);
    910                     }
     907                    warnOfCircularReferences(p);
    911908                    continue;
    912909                } else if (MemberTableModel.hasMembersReferringTo(relation.getMembers(), Collections.singleton(p))
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditorTest.java

    r14138 r14385  
    22package org.openstreetmap.josm.gui.dialogs.relation;
    33
     4import static org.junit.Assert.assertEquals;
    45import static org.junit.Assert.assertNotNull;
    56import static org.junit.Assert.assertNull;
     
    78import java.util.Collections;
    89
     10import javax.swing.JOptionPane;
    911import javax.swing.JPanel;
    1012
     
    2123import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
    2224import org.openstreetmap.josm.testutils.JOSMTestRules;
     25import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    2326
    2427import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    8386    @Test
    8487    public void testAddPrimitivesToRelation() {
     88        TestUtils.assumeWorkingJMockit();
     89        final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker();
     90
    8591        Relation r = TestUtils.addFakeDataSet(new Relation(1));
    8692        assertNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.<OsmPrimitive>emptyList()));
     93
     94        jopsMocker.getMockResultMap().put(
     95            "<html>You are trying to add a relation to itself.<br><br>This creates circular references "
     96            + "and is therefore discouraged.<br>Skipping relation 'incomplete'.</html>",
     97            JOptionPane.OK_OPTION
     98        );
     99
    87100        assertNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.singleton(new Relation(1))));
     101
     102        assertEquals(1, jopsMocker.getInvocationLog().size());
     103        Object[] invocationLogEntry = jopsMocker.getInvocationLog().get(0);
     104        assertEquals(JOptionPane.OK_OPTION, (int) invocationLogEntry[0]);
     105        assertEquals("Warning", invocationLogEntry[2]);
    88106
    89107        assertNotNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.singleton(new Node(1))));
    90108        assertNotNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.singleton(new Way(1))));
    91109        assertNotNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.singleton(new Relation(2))));
     110
     111        assertEquals(1, jopsMocker.getInvocationLog().size());
    92112    }
    93113
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/RelationEditorActionsTest.java

    r14380 r14385  
    1111import javax.swing.text.JTextComponent;
    1212
     13import org.openstreetmap.josm.TestUtils;
     14import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
    1315import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    14 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
    1516
    1617import com.google.common.collect.ImmutableMap;
     
    7172    @Test
    7273    public void testDeleteCurrentRelationAction() {
     74        TestUtils.assumeWorkingJMockit();
    7375        final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker(
    7476            ImmutableMap.<String, Object>of(
     
    107109    @Test
    108110    public void testSetRoleAction() {
     111        TestUtils.assumeWorkingJMockit();
    109112        final JOptionPaneSimpleMocker.MessagePanelMocker mpMocker = new JOptionPaneSimpleMocker.MessagePanelMocker();
    110113        // JOptionPaneSimpleMocker doesn't handle showOptionDialog calls because of their potential
Note: See TracChangeset for help on using the changeset viewer.