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 {
|
| 81 | 81 | this.sourceButtonGroup.add(menuItem); |
| 82 | 82 | |
| 83 | 83 | // 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())); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | pm.addSeparator(); |
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 {
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
| | 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 | /** |
| 223 | 260 | * Tests minimap obeys a saved "mapstyle" preference on startup. |
| 224 | 261 | * @throws Exception if any error occurs |
| 225 | 262 | */ |