diff --git a/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java b/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java
index 2964707..7c9ee79 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.TMSLayer;
|
| 15 | 15 | import org.openstreetmap.josm.gui.layer.WMSLayer; |
| 16 | 16 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 17 | 17 | |
| | 18 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 19 | |
| 18 | 20 | /** |
| 19 | 21 | * Unit tests for class {@link AddImageryLayerAction}. |
| 20 | 22 | */ |
| … |
… |
public final class AddImageryLayerActionTest {
|
| 23 | 25 | * We need prefs for this. We need platform for actions and the OSM API for checking blacklist. |
| 24 | 26 | */ |
| 25 | 27 | @Rule |
| | 28 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 26 | 29 | public JOSMTestRules test = new JOSMTestRules().preferences().platform().fakeAPI(); |
| 27 | 30 | |
| 28 | 31 | /** |
diff --git a/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java b/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java
index 2d8bad6..83f9bfb 100644
|
a
|
b
|
import javax.swing.JFrame;
|
| 12 | 12 | |
| 13 | 13 | import org.CustomMatchers; |
| 14 | 14 | import org.junit.Before; |
| 15 | | import org.junit.BeforeClass; |
| | 15 | import org.junit.Rule; |
| 16 | 16 | import org.junit.Test; |
| 17 | | import org.openstreetmap.josm.JOSMFixture; |
| 18 | 17 | import org.openstreetmap.josm.Main; |
| 19 | 18 | import org.openstreetmap.josm.data.Bounds; |
| 20 | 19 | import org.openstreetmap.josm.data.ProjectionBounds; |
| 21 | 20 | import org.openstreetmap.josm.data.coor.EastNorth; |
| 22 | 21 | import org.openstreetmap.josm.data.coor.LatLon; |
| 23 | 22 | import org.openstreetmap.josm.gui.util.GuiHelper; |
| | 23 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 24 | |
| | 25 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 24 | 26 | |
| 25 | 27 | /** |
| 26 | 28 | * Some tests for the {@link NavigatableComponent} class. |
| … |
… |
public class NavigatableComponentTest {
|
| 34 | 36 | private NavigatableComponent component; |
| 35 | 37 | |
| 36 | 38 | /** |
| 37 | | * Setup test. |
| | 39 | * We need the projection for coordinate conversions. |
| 38 | 40 | */ |
| 39 | | @BeforeClass |
| 40 | | public static void setUpBeforeClass() { |
| 41 | | JOSMFixture.createUnitTestFixture().init(); |
| 42 | | } |
| | 41 | @Rule |
| | 42 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| | 43 | public JOSMTestRules test = new JOSMTestRules().preferences().platform().projection(); |
| 43 | 44 | |
| 44 | 45 | /** |
| 45 | 46 | * Create a new, fresh {@link NavigatableComponent} |
diff --git a/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java b/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
index 7ca2b75..2531d0e 100644
|
a
|
b
|
import org.junit.runner.Description;
|
| 11 | 11 | import org.junit.runners.model.InitializationError; |
| 12 | 12 | import org.junit.runners.model.Statement; |
| 13 | 13 | import org.openstreetmap.josm.Main; |
| | 14 | import org.openstreetmap.josm.data.projection.Projections; |
| 14 | 15 | import org.openstreetmap.josm.gui.layer.MainLayerManager; |
| 15 | 16 | import org.openstreetmap.josm.gui.util.GuiHelper; |
| 16 | 17 | import org.openstreetmap.josm.io.OsmApi; |
| … |
… |
public class JOSMTestRules implements TestRule {
|
| 34 | 35 | private APIType useAPI = APIType.NONE; |
| 35 | 36 | private String i18n = null; |
| 36 | 37 | private boolean platform; |
| | 38 | private boolean useProjection; |
| 37 | 39 | |
| 38 | 40 | /** |
| 39 | 41 | * Disable the default timeout for this test. Use with care. |
| … |
… |
public class JOSMTestRules implements TestRule {
|
| 119 | 121 | return this; |
| 120 | 122 | } |
| 121 | 123 | |
| | 124 | /** |
| | 125 | * Set up default projection (Mercator) |
| | 126 | * @return this instance, for easy chaining |
| | 127 | */ |
| | 128 | public JOSMTestRules projection() { |
| | 129 | useProjection = true; |
| | 130 | return this; |
| | 131 | } |
| | 132 | |
| 122 | 133 | @Override |
| 123 | 134 | public Statement apply(final Statement base, Description description) { |
| 124 | 135 | Statement statement = new Statement() { |
| … |
… |
public class JOSMTestRules implements TestRule {
|
| 173 | 184 | Main.pref.put("osm-server.url", "http://invalid"); |
| 174 | 185 | } |
| 175 | 186 | |
| | 187 | if (useProjection) { |
| | 188 | Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator |
| | 189 | } |
| | 190 | |
| 176 | 191 | // Set API |
| 177 | 192 | if (useAPI == APIType.DEV) { |
| 178 | 193 | Main.pref.put("osm-server.url", "http://api06.dev.openstreetmap.org/api"); |
| … |
… |
public class JOSMTestRules implements TestRule {
|
| 213 | 228 | } |
| 214 | 229 | |
| 215 | 230 | // TODO: Remove global listeners and other global state. |
| 216 | | |
| 217 | 231 | Main.pref = null; |
| 218 | 232 | Main.platform = null; |
| 219 | 233 | // Parts of JOSM uses weak references - destroy them. |