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
|
|
1 | 1 | // License: GPL. For details, see LICENSE file. |
2 | 2 | package org.openstreetmap.josm.gui.preferences.advanced; |
3 | 3 | |
4 | | import org.junit.BeforeClass; |
| 4 | import javax.swing.JOptionPane; |
| 5 | |
| 6 | import org.junit.Rule; |
5 | 7 | import org.junit.Test; |
6 | | import org.openstreetmap.josm.JOSMFixture; |
7 | 8 | import org.openstreetmap.josm.Main; |
8 | 9 | |
| 10 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 11 | import org.openstreetmap.josm.testutils.JOptionPaneSimpleMocker; |
| 12 | |
| 13 | import com.google.common.collect.ImmutableMap; |
| 14 | |
| 15 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 16 | |
9 | 17 | /** |
10 | 18 | * Unit tests of {@link ExportProfileAction} class. |
11 | 19 | */ |
12 | 20 | public class ExportProfileActionTest { |
13 | | |
14 | 21 | /** |
15 | | * Setup test. |
| 22 | * Setup tests |
16 | 23 | */ |
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(); |
21 | 27 | |
22 | 28 | /** |
23 | 29 | * Unit test of {@link ExportProfileAction#actionPerformed}. |
24 | 30 | */ |
25 | 31 | @Test |
26 | 32 | public void testAction() { |
| 33 | new JOptionPaneSimpleMocker(ImmutableMap.of( |
| 34 | "All the preferences of this group are default, nothing to save", JOptionPane.OK_OPTION |
| 35 | )); |
27 | 36 | new ExportProfileAction(Main.pref, "foo", "bar").actionPerformed(null); |
28 | 37 | new ExportProfileAction(Main.pref, "expert", "expert").actionPerformed(null); |
29 | 38 | } |