Ticket #16010: v2-0010-ExportProfileActionTest-convert-to-use-of-JOSMTes.patch

File v2-0010-ExportProfileActionTest-convert-to-use-of-JOSMTes.patch, 2.3 KB (added by ris, 6 years ago)
  • test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java

    From d2466dae62b88b19e648c2fcb24eb428e2ad974c Mon Sep 17 00:00:00 2001
    From: Robert Scott <code@humanleg.org.uk>
    Date: Mon, 19 Mar 2018 00:05:47 +0000
    Subject: [PATCH v2 10/28] ExportProfileActionTest: convert to use of
     JOSMTestRules & JOptionPaneSimpleMocker
    
    won't yet have an effect until internal isHeadless() checks are removed
    ---
     .../advanced/ExportProfileActionTest.java          | 25 +++++++++++++++-------
     1 file changed, 17 insertions(+), 8 deletions(-)
    
    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java
    index 776fae9e5..c4c706364 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.preferences.advanced;
    33
    4 import org.junit.BeforeClass;
     4import javax.swing.JOptionPane;
     5
     6import org.junit.Rule;
    57import org.junit.Test;
    6 import org.openstreetmap.josm.JOSMFixture;
    78import org.openstreetmap.josm.Main;
    89
     10import org.openstreetmap.josm.testutils.JOSMTestRules;
     11import org.openstreetmap.josm.testutils.JOptionPaneSimpleMocker;
     12
     13import com.google.common.collect.ImmutableMap;
     14
     15import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     16
    917/**
    1018 * Unit tests of {@link ExportProfileAction} class.
    1119 */
    1220public class ExportProfileActionTest {
    13 
    1421    /**
    15      * Setup test.
     22     * Setup tests
    1623     */
    17     @BeforeClass
    18     public static void setUpBeforeClass() {
    19         JOSMFixture.createUnitTestFixture().init();
    20     }
     24    @Rule
     25    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     26    public JOSMTestRules test = new JOSMTestRules().preferences().assertionsInEDT();
    2127
    2228    /**
    2329     * Unit test of {@link ExportProfileAction#actionPerformed}.
    2430     */
    2531    @Test
    2632    public void testAction() {
     33        new JOptionPaneSimpleMocker(ImmutableMap.of(
     34            "All the preferences of this group are default, nothing to save", JOptionPane.OK_OPTION
     35        ));
    2736        new ExportProfileAction(Main.pref, "foo", "bar").actionPerformed(null);
    2837        new ExportProfileAction(Main.pref, "expert", "expert").actionPerformed(null);
    2938    }