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 {
|
| 231 | 231 | |
| 232 | 232 | assertEquals(1, haMocker.getInvocationLog().size()); |
| 233 | 233 | Object[] invocationLogEntry = haMocker.getInvocationLog().get(0); |
| 234 | | assertEquals(2, (int) invocationLogEntry[0]); |
| | 234 | assertEquals(1, (int) invocationLogEntry[0]); |
| 235 | 235 | assertEquals("Restart", invocationLogEntry[2]); |
| 236 | 236 | |
| 237 | 237 | // dummy_plugin jar shouldn't have been updated |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 353 | 353 | |
| 354 | 354 | assertEquals(1, haMocker.getInvocationLog().size()); |
| 355 | 355 | Object[] invocationLogEntry = haMocker.getInvocationLog().get(0); |
| 356 | | assertEquals(2, (int) invocationLogEntry[0]); |
| | 356 | assertEquals(1, (int) invocationLogEntry[0]); |
| 357 | 357 | assertEquals("Restart", invocationLogEntry[2]); |
| 358 | 358 | |
| 359 | 359 | // dummy_plugin jar shouldn't have been updated |
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
|
| 100 | 100 | Arrays.toString(Arrays.stream(options).map((buttonSpec) -> buttonSpec.text).toArray()) |
| 101 | 101 | )); |
| 102 | 102 | } |
| 103 | | // buttons are numbered with 1-based indexing |
| 104 | | return optIndex.getAsInt() + 1; |
| | 103 | return optIndex.getAsInt(); |
| 105 | 104 | } |
| 106 | 105 | } |
| 107 | 106 | |
| … |
… |
public class HelpAwareOptionPaneMocker extends BaseDialogMockUp<HelpAwareOptionP
|
| 161 | 160 | + "JOptionPane.OK_OPTION for closed windows if that was the intent)", |
| 162 | 161 | retval |
| 163 | 162 | )); |
| 164 | | } else if (retval > (options == null ? 0 : options.length)) { // NOTE 1-based indexing |
| | 163 | } else if (retval > (options == null ? 0 : options.length-1)) { |
| 165 | 164 | fail(String.format( |
| 166 | 165 | "Invalid result for HelpAwareOptionPane: %s (in call with options = %s)", |
| 167 | 166 | retval, |