Changeset 11781 in josm


Ignore:
Timestamp:
2017-03-26T13:52:10+02:00 (7 months ago)
Author:
michael2402
Message:

Update StyleCacheTest: Clear the style cache before each test. Add documentation.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r11589 r11781  
    254254    }
    255255
     256    /**
     257     * Reloads all styles from the preferences.
     258     */
    256259    public static void readFromPreferences() {
    257260        styles.clear();
  • trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java

    r11553 r11781  
    4949    }
    5050
     51    /**
     52     * Get the style for a specific style. Returns the range as well.
     53     * @param scale The current scale
     54     * @param selected true to get the state for a selected element,
     55     * @return The style and the range it is valid for.
     56     */
    5157    public Pair<StyleElementList, Range> getWithRange(double scale, boolean selected) {
    5258        int idx = getIndex(selected);
     
    8894
    8995    /**
     96     * Clears the style cache. This should only be used for testing.
     97     * It may be removed some day and replaced by a WeakReference implementation that automatically forgets old entries.
     98     */
     99    static void clearStyleCachePool() {
     100        internPool.clear();
     101    }
     102
     103    /**
    90104     * Get the size of the intern pool. Only for tests!
    91105     * @return size of the intern pool
  • trunk/test/functional/org/openstreetmap/josm/gui/mappaint/StyleCacheTest.java

    r11778 r11781  
    1717import org.junit.Rule;
    1818import org.junit.Test;
    19 import org.openstreetmap.josm.JOSMFixture;
    2019import org.openstreetmap.josm.Main;
    2120import org.openstreetmap.josm.data.Bounds;
     
    5352    @Rule
    5453    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    55     public JOSMTestRules test = new JOSMTestRules().preferences().platform().projection().mapStyles();
     54    public JOSMTestRules test = new JOSMTestRules().preferences().platform().projection().mapStyles().timeout(60000);
    5655
    5756    /**
     
    112111    @Test
    113112    public void testStyleCacheInternPool() {
    114         // This can be removed if there was no dependency on Main.map in some MapCSS conditions. See #14572
    115         JOSMFixture.createFunctionalTestFixture().init(true);
    116 
     113        StyleCache.clearStyleCachePool();
    117114        Bounds bounds = new Bounds(53.56, 13.25, 53.57, 13.26);
    118115        Rendering visitor = new StyledMapRenderer(g, nc, false);
     
    141138    @Test
    142139    public void testStyleCacheInternPool2() {
    143         // This can be removed if there was no dependency on Main.map in some MapCSS conditions. See #14572
    144         JOSMFixture.createFunctionalTestFixture().init(true);
    145 
     140        StyleCache.clearStyleCachePool();
    146141        Bounds bounds = new Bounds(53.56, 13.25, 53.57, 13.26);
    147142        Rendering visitor = new StyledMapRenderer(g, nc, false);
Note: See TracChangeset for help on using the changeset viewer.