kopia lustrzana https://github.com/JOSM/MapWithAI
Allow test to run in headless mode and add mocker for OpenBrowser
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
ad7c658b2b
commit
a9c06e44df
|
@ -1,7 +1,6 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
// License: GPL. For details, see LICENSE file.
|
||||||
package org.openstreetmap.josm.plugins.mapwithai;
|
package org.openstreetmap.josm.plugins.mapwithai;
|
||||||
|
|
||||||
import static org.junit.Assume.assumeFalse;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
@ -11,8 +10,11 @@ import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.openstreetmap.josm.TestUtils;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.OpenBrowserMocker;
|
||||||
import org.openstreetmap.josm.spi.preferences.Config;
|
import org.openstreetmap.josm.spi.preferences.Config;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
|
import org.openstreetmap.josm.testutils.mockers.WindowMocker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the update prod
|
* Test the update prod
|
||||||
|
@ -25,7 +27,11 @@ public class UpdateProdTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoProd() {
|
public void testDoProd() {
|
||||||
assumeFalse(GraphicsEnvironment.isHeadless());
|
TestUtils.assumeWorkingJMockit();
|
||||||
|
new OpenBrowserMocker();
|
||||||
|
if (GraphicsEnvironment.isHeadless()) {
|
||||||
|
new WindowMocker();
|
||||||
|
}
|
||||||
String booleanKey = "message.".concat(MapWithAIPlugin.NAME.concat(".ignore_next_version"));
|
String booleanKey = "message.".concat(MapWithAIPlugin.NAME.concat(".ignore_next_version"));
|
||||||
String intKey = "message.".concat(MapWithAIPlugin.NAME.concat(".ignore_next_version")).concat(".value"); // "message.MapWithAI.ignore_next_version.value";
|
String intKey = "message.".concat(MapWithAIPlugin.NAME.concat(".ignore_next_version")).concat(".value"); // "message.MapWithAI.ignore_next_version.value";
|
||||||
Config.getPref().putBoolean(booleanKey, false);
|
Config.getPref().putBoolean(booleanKey, false);
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package org.openstreetmap.josm.plugins.mapwithai.testutils;
|
||||||
|
|
||||||
|
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.openstreetmap.josm.tools.CheckParameterUtil;
|
||||||
|
import org.openstreetmap.josm.tools.Logging;
|
||||||
|
import org.openstreetmap.josm.tools.OpenBrowser;
|
||||||
|
|
||||||
|
import mockit.Mock;
|
||||||
|
import mockit.MockUp;
|
||||||
|
|
||||||
|
public class OpenBrowserMocker extends MockUp<OpenBrowser> {
|
||||||
|
@Mock
|
||||||
|
public static String displayUrl(URI uri) {
|
||||||
|
CheckParameterUtil.ensureParameterNotNull(uri, "uri");
|
||||||
|
|
||||||
|
Logging.debug(tr("Opening URL: {0}", uri));
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
Ładowanie…
Reference in New Issue