Changeset 9607 in josm


Ignore:
Timestamp:
2016-01-24T04:05:06+01:00 (4 years ago)
Author:
Don-vip
Message:

ConflictDialog: fix findbugs issue, add unit test

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java

    r9601 r9607  
    512512    }
    513513
    514     class ConflictPainter extends AbstractVisitor {
     514    /**
     515     * Paints conflicts.
     516     */
     517    public static class ConflictPainter extends AbstractVisitor {
    515518        // Manage a stack of visited relations to avoid infinite recursion with cyclic relations (fix #7938)
    516519        private final Set<Relation> visited = new HashSet<>();
     
    529532        }
    530533
    531         public void visit(Node n1, Node n2) {
     534        private void visit(Node n1, Node n2) {
    532535            Point p1 = nc.getPoint(n1);
    533536            Point p2 = nc.getPoint(n2);
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/ConflictDialogTest.java

    r9601 r9607  
    66
    77import java.awt.Color;
     8import java.awt.image.BufferedImage;
    89
    910import org.junit.BeforeClass;
    1011import org.junit.Test;
    1112import org.openstreetmap.josm.JOSMFixture;
     13import org.openstreetmap.josm.Main;
     14import org.openstreetmap.josm.data.osm.Node;
     15import org.openstreetmap.josm.data.osm.Relation;
     16import org.openstreetmap.josm.data.osm.RelationMember;
     17import org.openstreetmap.josm.data.osm.Way;
     18import org.openstreetmap.josm.gui.dialogs.ConflictDialog.ConflictPainter;
    1219
    1320/**
     
    3946        assertEquals(Color.gray, ConflictDialog.getColor());
    4047    }
     48
     49    /**
     50     * Unit tests of {@link ConflictPainter} class.
     51     */
     52    @Test
     53    public void testConflictPainter() {
     54        ConflictPainter cp = new ConflictPainter(Main.map.mapView, new BufferedImage(800, 600, BufferedImage.TYPE_3BYTE_BGR).createGraphics());
     55        Node n1 = new Node(1, 1);
     56        Node n2 = new Node(2, 1);
     57        Way w = new Way(1, 1);
     58        w.addNode(n1);
     59        w.addNode(n2);
     60        Relation r = new Relation(1, 1);
     61        r.addMember(new RelationMember("outer", w));
     62        cp.visit(n1);
     63        cp.visit(n2);
     64        cp.visit(w);
     65        cp.visit(r);
     66    }
    4167}
Note: See TracChangeset for help on using the changeset viewer.