1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.preferences.advanced;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 | import static org.junit.Assert.assertNotNull;
|
---|
6 | import static org.junit.Assert.assertTrue;
|
---|
7 |
|
---|
8 | import java.util.Arrays;
|
---|
9 |
|
---|
10 | import org.junit.BeforeClass;
|
---|
11 | import org.junit.Test;
|
---|
12 | import org.openstreetmap.josm.JOSMFixture;
|
---|
13 | import org.openstreetmap.josm.gui.preferences.advanced.ListEditor.ListSettingTableModel;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Unit tests of {@link ListEditor} class.
|
---|
17 | */
|
---|
18 | public class ListEditorTest {
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Setup test.
|
---|
22 | */
|
---|
23 | @BeforeClass
|
---|
24 | public static void setUpBeforeClass() {
|
---|
25 | JOSMFixture.createUnitTestFixture().init();
|
---|
26 | }
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Unit test of {@link ListSettingTableModel} class.
|
---|
30 | */
|
---|
31 | @Test
|
---|
32 | public void testListSettingTableModel() {
|
---|
33 | ListSettingTableModel model = new ListSettingTableModel(null);
|
---|
34 | assertNotNull(model.getData());
|
---|
35 | model = new ListSettingTableModel(Arrays.asList("foo"));
|
---|
36 | assertTrue(model.getData().contains("foo"));
|
---|
37 | assertEquals(2, model.getRowCount());
|
---|
38 | assertEquals(1, model.getColumnCount());
|
---|
39 | assertEquals("foo", model.getValueAt(0, 0));
|
---|
40 | assertEquals("", model.getValueAt(1, 0));
|
---|
41 | assertTrue(model.isCellEditable(0, 0));
|
---|
42 | model.setValueAt("bar", 0, 0);
|
---|
43 | assertEquals("bar", model.getValueAt(0, 0));
|
---|
44 | model.setValueAt("test", 1, 0);
|
---|
45 | assertEquals("test", model.getValueAt(1, 0));
|
---|
46 | assertEquals(3, model.getRowCount());
|
---|
47 | }
|
---|
48 | }
|
---|