1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.dialogs;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
5 |
|
---|
6 | import java.util.Date;
|
---|
7 |
|
---|
8 | import javax.swing.JLabel;
|
---|
9 | import javax.swing.JList;
|
---|
10 |
|
---|
11 | import org.junit.jupiter.api.Test;
|
---|
12 | import org.junit.jupiter.api.extension.RegisterExtension;
|
---|
13 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
14 | import org.openstreetmap.josm.data.notes.Note;
|
---|
15 | import org.openstreetmap.josm.data.notes.NoteComment;
|
---|
16 | import org.openstreetmap.josm.data.osm.User;
|
---|
17 | import org.openstreetmap.josm.gui.dialogs.NotesDialog.NoteRenderer;
|
---|
18 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
19 |
|
---|
20 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Unit tests of {@link NotesDialog}
|
---|
24 | */
|
---|
25 | class 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 | }
|
---|