source: josm/trunk/test/unit/org/openstreetmap/josm/gui/dialogs/NotesDialogTest.java@ 17269

Last change on this file since 17269 was 17269, checked in by Don-vip, 3 years ago

fix #19993 - handle multiline note comments in notes dialog

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5
6import java.util.Date;
7
8import javax.swing.JLabel;
9import javax.swing.JList;
10
11import org.junit.jupiter.api.Test;
12import org.junit.jupiter.api.extension.RegisterExtension;
13import org.openstreetmap.josm.data.coor.LatLon;
14import org.openstreetmap.josm.data.notes.Note;
15import org.openstreetmap.josm.data.notes.NoteComment;
16import org.openstreetmap.josm.data.osm.User;
17import org.openstreetmap.josm.gui.dialogs.NotesDialog.NoteRenderer;
18import org.openstreetmap.josm.testutils.JOSMTestRules;
19
20import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
21
22/**
23 * Unit tests of {@link NotesDialog}
24 */
25class NotesDialogTest {
26
27 /**
28 * Setup tests
29 */
30 @RegisterExtension
31 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
32 public JOSMTestRules josmTestRules = new JOSMTestRules().preferences();
33
34 @Test
35 void testMultiLineNoteRendering() {
36 Note note = new Note(LatLon.ZERO);
37 note.setCreatedAt(new Date());
38 note.addComment(new NoteComment(new Date(), User.createLocalUser(null), "foo\nbar\n\nbaz:\nfoo", null, false));
39 assertEquals("0: foo; bar; baz: foo",
40 ((JLabel) new NoteRenderer().getListCellRendererComponent(new JList<>(), note, 0, false, false)).getText());
41 }
42}
Note: See TracBrowser for help on using the repository browser.