Changeset 13172 in josm


Ignore:
Timestamp:
2017-11-27T20:39:30+01:00 (2 weeks ago)
Author:
Don-vip
Message:

see #15599 - apply first two patches of ris to improve MinimapDialogTest

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java

    r13112 r13172  
    5555    }
    5656
    57     private static void assertSingleSelectedSourceLabel(JPopupMenu menu, String label) {
     57    protected void assertSingleSelectedSourceLabel(String label) {
     58        JPopupMenu menu = this.sourceButton.getPopupMenu();
    5859        boolean found = false;
    5960        for (Component c: menu.getComponents()) {
     
    7374    }
    7475
    75     private static JMenuItem getSourceMenuItemByLabel(JPopupMenu menu, String label) {
     76    protected JMenuItem getSourceMenuItemByLabel(String label) {
     77        JPopupMenu menu = this.sourceButton.getPopupMenu();
    7678        for (Component c: menu.getComponents()) {
    7779            if (JPopupMenu.Separator.class.isInstance(c)) {
     
    8991    protected SlippyMapBBoxChooser slippyMap;
    9092    protected SourceButton sourceButton;
     93    protected Callable<Boolean> slippyMapTasksFinished;
    9194
    9295    protected static BufferedImage paintedSlippyMap;
     
    99102        this.sourceButton = (SourceButton) TestUtils.getPrivateField(this.slippyMap, "iSourceButton");
    100103
    101         // get dlg in a paintable state
     104        this.slippyMapTasksFinished = () -> !this.slippyMap.getTileController().getTileLoader().hasOutstandingTasks();
     105
     106        // get minimap in a paintable state
    102107        this.minimap.addNotify();
    103108        this.minimap.doLayout();
     
    126131    }
    127132
    128     protected Callable<Boolean> slippyMapTasksFinished() {
    129         return () -> !this.slippyMap.getTileController().getTileLoader().hasOutstandingTasks();
    130     }
    131 
    132133    /**
    133134     * Tests to switch imagery source.
     
    144145        this.paintSlippyMap();
    145146
    146         Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished());
     147        Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished);
    147148
    148149        this.paintSlippyMap();
     
    150151        assertEquals(0xffffffff, paintedSlippyMap.getRGB(0, 0));
    151152
    152         assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "White Tiles");
    153 
    154         getSourceMenuItemByLabel(this.sourceButton.getPopupMenu(), "Magenta Tiles").doClick();
    155         assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "Magenta Tiles");
     153        this.assertSingleSelectedSourceLabel("White Tiles");
     154
     155        this.getSourceMenuItemByLabel("Magenta Tiles").doClick();
     156        this.assertSingleSelectedSourceLabel("Magenta Tiles");
    156157        // call paint to trigger new tile fetch
    157158        this.paintSlippyMap();
    158159
    159         Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished());
     160        Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished);
    160161
    161162        this.paintSlippyMap();
     
    163164        assertEquals(0xffff00ff, paintedSlippyMap.getRGB(0, 0));
    164165
    165         getSourceMenuItemByLabel(this.sourceButton.getPopupMenu(), "Green Tiles").doClick();
    166         assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "Green Tiles");
     166        this.getSourceMenuItemByLabel("Green Tiles").doClick();
     167        this.assertSingleSelectedSourceLabel("Green Tiles");
    167168        // call paint to trigger new tile fetch
    168169        this.paintSlippyMap();
    169170
    170         Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished());
     171        Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished);
    171172
    172173        this.paintSlippyMap();
     
    187188        this.setUpMiniMap();
    188189
    189         assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "Green Tiles");
     190        this.assertSingleSelectedSourceLabel("Green Tiles");
    190191
    191192        // an initial paint operation is required to trigger the tile fetches
    192193        this.paintSlippyMap();
    193194
    194         Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished());
     195        Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished);
    195196
    196197        this.paintSlippyMap();
     
    198199        assertEquals(0xff00ff00, paintedSlippyMap.getRGB(0, 0));
    199200
    200         getSourceMenuItemByLabel(this.sourceButton.getPopupMenu(), "Magenta Tiles").doClick();
    201         assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "Magenta Tiles");
     201        this.getSourceMenuItemByLabel("Magenta Tiles").doClick();
     202        this.assertSingleSelectedSourceLabel("Magenta Tiles");
    202203
    203204        assertEquals("Magenta Tiles", Main.pref.get("slippy_map_chooser.mapstyle", "Fail"));
     
    214215        this.setUpMiniMap();
    215216
    216         assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "White Tiles");
     217        this.assertSingleSelectedSourceLabel("White Tiles");
    217218
    218219        // an initial paint operation is required to trigger the tile fetches
    219220        this.paintSlippyMap();
    220221
    221         Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished());
     222        Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished);
    222223
    223224        this.paintSlippyMap();
Note: See TracChangeset for help on using the changeset viewer.