source: josm/trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellRendererTest.java@ 9919

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

add more unit tests

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.conflict.tags;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertNotNull;
6
7import java.util.Arrays;
8import java.util.Collections;
9
10import javax.swing.JTable;
11
12import org.junit.BeforeClass;
13import org.junit.Test;
14import org.openstreetmap.josm.JOSMFixture;
15import org.openstreetmap.josm.data.osm.Tag;
16import org.openstreetmap.josm.data.osm.TagCollection;
17
18/**
19 * Unit tests of {@link MultiValueCellRenderer} class.
20 */
21public class MultiValueCellRendererTest {
22
23 /**
24 * Setup test.
25 */
26 @BeforeClass
27 public static void setUpBeforeClass() {
28 JOSMFixture.createUnitTestFixture().init();
29 }
30
31 /**
32 * Unit test of {@link MultiValueCellRenderer#MultiValueCellRenderer}.
33 */
34 @Test
35 public void testMultiValueCellRenderer() {
36 TagConflictResolverModel model = new TagConflictResolverModel();
37 TagCollection tags = new TagCollection(Arrays.asList(new Tag("oneway", "yes"), new Tag("oneway", "no")));
38 model.populate(tags, Collections.singleton("oneway"));
39 JTable table = new JTable(model);
40 MultiValueResolutionDecision decision = new MultiValueResolutionDecision(tags);
41 MultiValueCellRenderer r = new MultiValueCellRenderer();
42 test(table, decision, r);
43 decision.keepAll();
44 test(table, decision, r);
45 decision.keepNone();
46 test(table, decision, r);
47 decision.keepOne("yes");
48 test(table, decision, r);
49 decision.sumAllNumeric();
50 test(table, decision, r);
51 decision.undecide();
52 test(table, decision, r);
53 }
54
55 private void test(JTable table, MultiValueResolutionDecision value, MultiValueCellRenderer r) {
56 assertEquals(r, r.getTableCellRendererComponent(table, value, false, false, 0, 0));
57 assertEquals(r, r.getTableCellRendererComponent(table, value, false, false, 0, 1));
58 assertNotNull(r.getTableCellRendererComponent(table, value, false, false, 0, 2));
59 assertEquals(r, r.getTableCellRendererComponent(table, value, true, false, 0, 0));
60 assertEquals(r, r.getTableCellRendererComponent(table, value, true, false, 0, 1));
61 assertNotNull(r.getTableCellRendererComponent(table, value, true, false, 0, 2));
62 }
63}
Note: See TracBrowser for help on using the repository browser.