Ticket #16809: v1-0001-SlippyMapBBoxChooser-correct-check-attempting-to-.patch

File v1-0001-SlippyMapBBoxChooser-correct-check-attempting-to-.patch, 3.0 KB (added by ris, 6 years ago)
  • src/org/openstreetmap/josm/gui/bbox/SourceButton.java

    From fd519471293b7706582c28640e06b064bc96558a Mon Sep 17 00:00:00 2001
    From: Robert Scott <code@humanleg.org.uk>
    Date: Sat, 29 Sep 2018 18:45:18 +0100
    Subject: [PATCH v1 1/4] SlippyMapBBoxChooser: correct check attempting to
     retain selection of TileSource when sources are refreshed
    
    add a test for the MinimapDialog covering this
    ---
     .../openstreetmap/josm/gui/bbox/SourceButton.java  |  2 +-
     .../josm/gui/dialogs/MinimapDialogTest.java        | 37 ++++++++++++++++++++++
     2 files changed, 38 insertions(+), 1 deletion(-)
    
    diff --git a/src/org/openstreetmap/josm/gui/bbox/SourceButton.java b/src/org/openstreetmap/josm/gui/bbox/SourceButton.java
    index d9236d6de..9a59d3e31 100644
    a b public class SourceButton extends PopupMenuButton {  
    8181            this.sourceButtonGroup.add(menuItem);
    8282
    8383            // attempt to initialize button group matching current state of slippyMapBBoxChooser
    84             buttonModel.setSelected(this.slippyMapBBoxChooser.getTileController().getTileSource() == ts);
     84            buttonModel.setSelected(this.slippyMapBBoxChooser.getTileController().getTileSource().getId().equals(ts.getId()));
    8585        }
    8686
    8787        pm.addSeparator();
  • test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java
    index a5de69ba8..f8a61a41b 100644
    a b public class MinimapDialogTest {  
    220220    }
    221221
    222222    /**
     223     * Tests that the apparently-selected TileSource survives the tile sources being refreshed.
     224     * @throws Exception if any error occurs
     225     */
     226    @Test
     227    public void testRefreshSourcesRetainsSelection() throws Exception {
     228        // relevant prefs starting out empty, should choose the first source and have shown download area enabled
     229        // (not that there's a data layer for it to use)
     230
     231        this.setUpMiniMap();
     232
     233        this.clickSourceMenuItemByLabel("Magenta Tiles");
     234        this.assertSingleSelectedSourceLabel("Magenta Tiles");
     235
     236        // call paint to trigger new tile fetch
     237        this.paintSlippyMap();
     238
     239        Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished);
     240
     241        this.paintSlippyMap();
     242
     243        assertEquals(0xffff00ff, paintedSlippyMap.getRGB(0, 0));
     244
     245        this.slippyMap.refreshTileSources();
     246
     247        this.assertSingleSelectedSourceLabel("Magenta Tiles");
     248
     249        // call paint to trigger new tile fetch
     250        this.paintSlippyMap();
     251
     252        Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished);
     253
     254        this.paintSlippyMap();
     255
     256        assertEquals(0xffff00ff, paintedSlippyMap.getRGB(0, 0));
     257    }
     258
     259    /**
    223260     * Tests minimap obeys a saved "mapstyle" preference on startup.
    224261     * @throws Exception if any error occurs
    225262     */