From f6963e3dec856a152e47c12e7551c464b196636b Mon Sep 17 00:00:00 2001
From: Robert Scott <code@humanleg.org.uk>
Date: Thu, 18 Oct 2018 20:38:42 +0100
Subject: [PATCH v1 1/2] OsmDataLayerTest: fix for non-headless mode
---
src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java | 3 ---
.../org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java | 13 +++++++++++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java b/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
index 6f0dd5057..651280050 100644
|
a
|
b
|
public class OsmDataLayer extends AbstractOsmDataLayer implements Listener, Data
|
| 1102 | 1102 | @Override |
| 1103 | 1103 | public boolean checkSaveConditions() { |
| 1104 | 1104 | if (isDataSetEmpty() && 1 != GuiHelper.runInEDTAndWaitAndReturn(() -> { |
| 1105 | | if (GraphicsEnvironment.isHeadless()) { |
| 1106 | | return 2; |
| 1107 | | } |
| 1108 | 1105 | return new ExtendedDialog( |
| 1109 | 1106 | MainApplication.getMainFrame(), |
| 1110 | 1107 | tr("Empty document"), |
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java
index 275d98173..9d8555dd3 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.MainApplication;
|
| 34 | 34 | import org.openstreetmap.josm.io.IllegalDataException; |
| 35 | 35 | import org.openstreetmap.josm.io.OsmReader; |
| 36 | 36 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 37 | import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; |
| 37 | 38 | import org.openstreetmap.josm.tools.date.DateUtils; |
| 38 | 39 | |
| | 40 | import com.google.common.collect.ImmutableMap; |
| | 41 | |
| 39 | 42 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 40 | 43 | |
| 41 | 44 | /** |
| … |
… |
public class OsmDataLayerTest {
|
| 279 | 282 | */ |
| 280 | 283 | @Test |
| 281 | 284 | 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 | |
| 282 | 290 | assertFalse(layer.checkSaveConditions()); |
| 283 | 291 | fillDataSet(ds); |
| 284 | 292 | assertTrue(layer.checkSaveConditions()); |
| | 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]); |
| 285 | 298 | } |
| 286 | 299 | |
| 287 | 300 | @Test |