Changeset 10402 in josm for trunk/test


Ignore:
Timestamp:
2016-06-16T16:37:27+02:00 (4 years ago)
Author:
Don-vip
Message:

fix #12977 - Use test rules for NavigatableComponentTest (patch by michael2402) - gsoc-core

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java

    r10396 r10402  
    1616import org.openstreetmap.josm.testutils.JOSMTestRules;
    1717
     18import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     19
    1820/**
    1921 * Unit tests for class {@link AddImageryLayerAction}.
     
    2426     */
    2527    @Rule
     28    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2629    public JOSMTestRules test = new JOSMTestRules().preferences().platform().fakeAPI();
    2730
  • trunk/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java

    r10375 r10402  
    1313import org.CustomMatchers;
    1414import org.junit.Before;
    15 import org.junit.BeforeClass;
     15import org.junit.Rule;
    1616import org.junit.Test;
    17 import org.openstreetmap.josm.JOSMFixture;
    1817import org.openstreetmap.josm.Main;
    1918import org.openstreetmap.josm.data.Bounds;
     
    2221import org.openstreetmap.josm.data.coor.LatLon;
    2322import org.openstreetmap.josm.gui.util.GuiHelper;
     23import org.openstreetmap.josm.testutils.JOSMTestRules;
     24
     25import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2426
    2527/**
     
    3537
    3638    /**
    37      * Setup test.
     39     * We need the projection for coordinate conversions.
    3840     */
    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();
    4344
    4445    /**
  • trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java

    r10373 r10402  
    1212import org.junit.runners.model.Statement;
    1313import org.openstreetmap.josm.Main;
     14import org.openstreetmap.josm.data.projection.Projections;
    1415import org.openstreetmap.josm.gui.layer.MainLayerManager;
    1516import org.openstreetmap.josm.gui.util.GuiHelper;
     
    3536    private String i18n = null;
    3637    private boolean platform;
     38    private boolean useProjection;
    3739
    3840    /**
     
    117119    public JOSMTestRules fakeAPI() {
    118120        useAPI = APIType.FAKE;
     121        return this;
     122    }
     123
     124    /**
     125     * Set up default projection (Mercator)
     126     * @return this instance, for easy chaining
     127     */
     128    public JOSMTestRules projection() {
     129        useProjection = true;
    119130        return this;
    120131    }
     
    174185        }
    175186
     187        if (useProjection) {
     188            Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     189        }
     190
    176191        // Set API
    177192        if (useAPI == APIType.DEV) {
     
    214229
    215230        // TODO: Remove global listeners and other global state.
    216 
    217231        Main.pref = null;
    218232        Main.platform = null;
Note: See TracChangeset for help on using the changeset viewer.