Ignore:
Timestamp:
2018-10-15T23:43:03+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #16845 - ChooseTrackVisibilityActionTest: fix for non-headless mode by properly mocking dialogs (patch by ris)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityActionTest.java

    r14138 r14337  
    22package org.openstreetmap.josm.gui.layer.gpx;
    33
     4import static org.junit.Assert.assertEquals;
     5
     6import javax.swing.JLabel;
     7import javax.swing.JPanel;
     8
    49import org.junit.Rule;
    510import org.junit.Test;
     11import org.openstreetmap.josm.gui.ExtendedDialog;
    612import org.openstreetmap.josm.gui.layer.GpxLayerTest;
    713import org.openstreetmap.josm.testutils.JOSMTestRules;
     14import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker;
    815
    916import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    2734    @Test
    2835    public void testAction() throws Exception {
     36        final ExtendedDialogMocker edMocker = new ExtendedDialogMocker() {
     37            protected String getString(final ExtendedDialog instance) {
     38                return ((JLabel) ((JPanel) this.getContent(instance)).getComponent(2)).getText();
     39            }
     40        };
     41        edMocker.getMockResultMap().put(
     42            "<html>Select all tracks that you want to be displayed. You can drag select a range of " +
     43            "tracks or use CTRL+Click to select specific ones. The map is updated live in the " +
     44            "background. Open the URLs by double clicking them.</html>",
     45            "Show all"
     46        );
     47
    2948        new ChooseTrackVisibilityAction(GpxLayerTest.getMinimalGpxLayer()).actionPerformed(null);
     49
     50        assertEquals(1, edMocker.getInvocationLog().size());
     51        Object[] invocationLogEntry = edMocker.getInvocationLog().get(0);
     52        assertEquals(1, (int) invocationLogEntry[0]);
     53        assertEquals("Set track visibility for Bananas", invocationLogEntry[2]);
    3054    }
    3155}
Note: See TracChangeset for help on using the changeset viewer.