From 4256eccf6ec646fed89f0e0931f8eb50ff97522c Mon Sep 17 00:00:00 2001
From: Robert Scott <code@humanleg.org.uk>
Date: Sun, 12 Nov 2017 19:07:11 +0000
Subject: [PATCH v1 1/6] MinimapDialogTest: switch all utility methods to
non-static, requiring fewer arguments
---
.../josm/gui/dialogs/MinimapDialogTest.java | 26 ++++++++++++----------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java
index 2fbb0a1fb..2e7267c15 100644
|
a
|
b
|
public class MinimapDialogTest {
|
| 54 | 54 | assertFalse(dlg.isVisible()); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | | private static void assertSingleSelectedSourceLabel(JPopupMenu menu, String label) { |
| | 57 | protected void assertSingleSelectedSourceLabel(String label) { |
| | 58 | JPopupMenu menu = this.sourceButton.getPopupMenu(); |
| 58 | 59 | boolean found = false; |
| 59 | 60 | for (Component c: menu.getComponents()) { |
| 60 | 61 | if (JPopupMenu.Separator.class.isInstance(c)) { |
| … |
… |
public class MinimapDialogTest {
|
| 72 | 73 | assertTrue("Selected source not found in menu", found); |
| 73 | 74 | } |
| 74 | 75 | |
| 75 | | private static JMenuItem getSourceMenuItemByLabel(JPopupMenu menu, String label) { |
| | 76 | protected JMenuItem getSourceMenuItemByLabel(String label) { |
| | 77 | JPopupMenu menu = this.sourceButton.getPopupMenu(); |
| 76 | 78 | for (Component c: menu.getComponents()) { |
| 77 | 79 | if (JPopupMenu.Separator.class.isInstance(c)) { |
| 78 | 80 | break; |
| … |
… |
public class MinimapDialogTest {
|
| 98 | 100 | this.slippyMap = (SlippyMapBBoxChooser) TestUtils.getPrivateField(this.minimap, "slippyMap"); |
| 99 | 101 | this.sourceButton = (SourceButton) TestUtils.getPrivateField(this.slippyMap, "iSourceButton"); |
| 100 | 102 | |
| 101 | | // get dlg in a paintable state |
| | 103 | // get minimap in a paintable state |
| 102 | 104 | this.minimap.addNotify(); |
| 103 | 105 | this.minimap.doLayout(); |
| 104 | 106 | } |
| … |
… |
public class MinimapDialogTest {
|
| 149 | 151 | |
| 150 | 152 | assertEquals(0xffffffff, paintedSlippyMap.getRGB(0, 0)); |
| 151 | 153 | |
| 152 | | assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "White Tiles"); |
| | 154 | this.assertSingleSelectedSourceLabel("White Tiles"); |
| 153 | 155 | |
| 154 | | getSourceMenuItemByLabel(this.sourceButton.getPopupMenu(), "Magenta Tiles").doClick(); |
| 155 | | assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "Magenta Tiles"); |
| | 156 | this.getSourceMenuItemByLabel("Magenta Tiles").doClick(); |
| | 157 | this.assertSingleSelectedSourceLabel("Magenta Tiles"); |
| 156 | 158 | // call paint to trigger new tile fetch |
| 157 | 159 | this.paintSlippyMap(); |
| 158 | 160 | |
| … |
… |
public class MinimapDialogTest {
|
| 162 | 164 | |
| 163 | 165 | assertEquals(0xffff00ff, paintedSlippyMap.getRGB(0, 0)); |
| 164 | 166 | |
| 165 | | getSourceMenuItemByLabel(this.sourceButton.getPopupMenu(), "Green Tiles").doClick(); |
| 166 | | assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "Green Tiles"); |
| | 167 | this.getSourceMenuItemByLabel("Green Tiles").doClick(); |
| | 168 | this.assertSingleSelectedSourceLabel("Green Tiles"); |
| 167 | 169 | // call paint to trigger new tile fetch |
| 168 | 170 | this.paintSlippyMap(); |
| 169 | 171 | |
| … |
… |
public class MinimapDialogTest {
|
| 186 | 188 | |
| 187 | 189 | this.setUpMiniMap(); |
| 188 | 190 | |
| 189 | | assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "Green Tiles"); |
| | 191 | this.assertSingleSelectedSourceLabel("Green Tiles"); |
| 190 | 192 | |
| 191 | 193 | // an initial paint operation is required to trigger the tile fetches |
| 192 | 194 | this.paintSlippyMap(); |
| … |
… |
public class MinimapDialogTest {
|
| 197 | 199 | |
| 198 | 200 | assertEquals(0xff00ff00, paintedSlippyMap.getRGB(0, 0)); |
| 199 | 201 | |
| 200 | | getSourceMenuItemByLabel(this.sourceButton.getPopupMenu(), "Magenta Tiles").doClick(); |
| 201 | | assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "Magenta Tiles"); |
| | 202 | this.getSourceMenuItemByLabel("Magenta Tiles").doClick(); |
| | 203 | this.assertSingleSelectedSourceLabel("Magenta Tiles"); |
| 202 | 204 | |
| 203 | 205 | assertEquals("Magenta Tiles", Main.pref.get("slippy_map_chooser.mapstyle", "Fail")); |
| 204 | 206 | } |
| … |
… |
public class MinimapDialogTest {
|
| 213 | 215 | |
| 214 | 216 | this.setUpMiniMap(); |
| 215 | 217 | |
| 216 | | assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "White Tiles"); |
| | 218 | this.assertSingleSelectedSourceLabel("White Tiles"); |
| 217 | 219 | |
| 218 | 220 | // an initial paint operation is required to trigger the tile fetches |
| 219 | 221 | this.paintSlippyMap(); |