Ticket #16010: v1-0001-HelpAwareOptionPaneMocker-remove-idea-of-result-o.patch

File v1-0001-HelpAwareOptionPaneMocker-remove-idea-of-result-o.patch, 3.1 KB (added by ris, 15 months ago)
  • test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java

    From a1b865f8b539206383d0eadd382c186d1631b93d Mon Sep 17 00:00:00 2001
    From: Robert Scott <code@humanleg.org.uk>
    Date: Sat, 28 Jul 2018 17:43:05 +0100
    Subject: [PATCH v1 1/2] HelpAwareOptionPaneMocker: remove idea of result
     option indexing being 1-based
    
    I don't know where I got this idea from.
    ---
     .../josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java   | 4 ++--
     .../josm/testutils/mockers/HelpAwareOptionPaneMocker.java            | 5 ++---
     2 files changed, 4 insertions(+), 5 deletions(-)
    
    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java
    index 876e0bfcd..10348fa20 100644
    a b public class PluginPreferenceHighLevelTest { 
    231231
    232232        assertEquals(1, haMocker.getInvocationLog().size());
    233233        Object[] invocationLogEntry = haMocker.getInvocationLog().get(0);
    234         assertEquals(2, (int) invocationLogEntry[0]);
     234        assertEquals(1, (int) invocationLogEntry[0]);
    235235        assertEquals("Restart", invocationLogEntry[2]);
    236236
    237237        // dummy_plugin jar shouldn't have been updated
    public class PluginPreferenceHighLevelTest { 
    353353
    354354        assertEquals(1, haMocker.getInvocationLog().size());
    355355        Object[] invocationLogEntry = haMocker.getInvocationLog().get(0);
    356         assertEquals(2, (int) invocationLogEntry[0]);
     356        assertEquals(1, (int) invocationLogEntry[0]);
    357357        assertEquals("Restart", invocationLogEntry[2]);
    358358
    359359        // dummy_plugin jar shouldn't have been updated
  • test/unit/org/openstreetmap/josm/testutils/mockers/HelpAwareOptionPaneMocker.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/mockers/HelpAwareOptionPaneMocker.java b/test/unit/org/openstreetmap/josm/testutils/mockers/HelpAwareOptionPaneMocker.java
    index 9eb7bbf41..9acef814a 100644
    a b public class HelpAwareOptionPaneMocker extends BaseDialogMockUp<HelpAwareOptionP 
    100100                    Arrays.toString(Arrays.stream(options).map((buttonSpec) -> buttonSpec.text).toArray())
    101101                ));
    102102            }
    103             // buttons are numbered with 1-based indexing
    104             return optIndex.getAsInt() + 1;
     103            return optIndex.getAsInt();
    105104        }
    106105    }
    107106
    public class HelpAwareOptionPaneMocker extends BaseDialogMockUp<HelpAwareOptionP 
    161160                    + "JOptionPane.OK_OPTION for closed windows if that was the intent)",
    162161                    retval
    163162                ));
    164             } else if (retval > (options == null ? 0 : options.length)) {  // NOTE 1-based indexing
     163            } else if (retval > (options == null ? 0 : options.length-1)) {
    165164                fail(String.format(
    166165                    "Invalid result for HelpAwareOptionPane: %s (in call with options = %s)",
    167166                    retval,