Changeset 14349 in josm


Ignore:
Timestamp:
2018-10-19T01:14:24+02:00 (7 months ago)
Author:
Don-vip
Message:

fix #16855 - OsmDataLayerTest: fix for non-headless mode (patch by ris)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r14182 r14349  
    1111import java.awt.Composite;
    1212import java.awt.Graphics2D;
    13 import java.awt.GraphicsEnvironment;
    1413import java.awt.GridBagLayout;
    1514import java.awt.Rectangle;
     
    11031102    public boolean checkSaveConditions() {
    11041103        if (isDataSetEmpty() && 1 != GuiHelper.runInEDTAndWaitAndReturn(() -> {
    1105             if (GraphicsEnvironment.isHeadless()) {
    1106                 return 2;
    1107             }
    11081104            return new ExtendedDialog(
    11091105                    MainApplication.getMainFrame(),
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java

    r14138 r14349  
    3535import org.openstreetmap.josm.io.OsmReader;
    3636import org.openstreetmap.josm.testutils.JOSMTestRules;
     37import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker;
    3738import org.openstreetmap.josm.tools.date.DateUtils;
     39
     40import com.google.common.collect.ImmutableMap;
    3841
    3942import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    280283    @Test
    281284    public void testCheckSaveConditions() {
     285        TestUtils.assumeWorkingJMockit();
     286        final ExtendedDialogMocker edMocker = new ExtendedDialogMocker(
     287            ImmutableMap.<String, Object>of("The document contains no data.", "Cancel")
     288        );
     289
    282290        assertFalse(layer.checkSaveConditions());
    283291        fillDataSet(ds);
    284292        assertTrue(layer.checkSaveConditions());
    285     }
    286 
     293
     294        assertEquals(1, edMocker.getInvocationLog().size());
     295        Object[] invocationLogEntry = edMocker.getInvocationLog().get(0);
     296        assertEquals(2, (int) invocationLogEntry[0]);
     297        assertEquals("Empty document", invocationLogEntry[2]);
     298    }
     299
     300    /**
     301     * Checks that unnamed layer number increases
     302     */
    287303    @Test
    288304    public void testLayerNameIncreases() throws Exception {
     
    293309    }
    294310
     311    /**
     312     * Checks that named layer got no number
     313     */
    295314    @Test
    296315    public void testLayerUnnumberedName() {
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityActionTest.java

    r14337 r14349  
    99import org.junit.Rule;
    1010import org.junit.Test;
     11import org.openstreetmap.josm.TestUtils;
    1112import org.openstreetmap.josm.gui.ExtendedDialog;
    1213import org.openstreetmap.josm.gui.layer.GpxLayerTest;
     
    3435    @Test
    3536    public void testAction() throws Exception {
     37        TestUtils.assumeWorkingJMockit();
    3638        final ExtendedDialogMocker edMocker = new ExtendedDialogMocker() {
     39            @Override
    3740            protected String getString(final ExtendedDialog instance) {
    3841                return ((JLabel) ((JPanel) this.getContent(instance)).getComponent(2)).getText();
Note: See TracChangeset for help on using the changeset viewer.