Skip to content

Commit 37a1972

Browse files
author
taylor.smock
committed
JosmTextField: setHint now properly returns the old hint
See #21319/r18221. This additionally adds a non-regression test. git-svn-id: https://josm.openstreetmap.de/svn/trunk@18538 0c6e7542-c601-0410-84e7-c038aed88b3b
1 parent b10709f commit 37a1972

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/org/openstreetmap/josm/gui/widgets/JosmTextField.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public final String getHint() {
180180
* @since 18221 (signature)
181181
*/
182182
public String setHint(String hint) {
183-
String old = hint;
183+
String old = this.hint;
184184
this.hint = hint;
185185
return old;
186186
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// License: GPL. For details, see LICENSE file.
2+
package org.openstreetmap.josm.gui.widgets;
3+
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
6+
import org.junit.jupiter.api.Test;
7+
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
8+
9+
/**
10+
* Test class for {@link JosmTextField}
11+
*/
12+
@BasicPreferences
13+
class JosmTextFieldTest {
14+
@Test
15+
void testSetHint() {
16+
JosmTextField josmTextField = new JosmTextField();
17+
josmTextField.setHint("some hint");
18+
assertEquals("some hint", josmTextField.getHint());
19+
assertEquals("some hint", josmTextField.setHint("new hint"));
20+
assertEquals("new hint", josmTextField.getHint());
21+
}
22+
}

0 commit comments

Comments
 (0)