Changeset 19624 in josm for trunk/test


Ignore:
Timestamp:
2026-09-16T10:31:15+02:00 (26 hours ago)
Author:
stoecker
Message:

fix #24891 - major improvements of parallel way action - patch by wangi

Location:
trunk/test/unit/org/openstreetmap/josm/actions/mapmode
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/mapmode/ParallelWayActionTest.java

    r19227 r19624  
    1313import org.openstreetmap.josm.data.coor.LatLon;
    1414import org.openstreetmap.josm.data.osm.DataSet;
     15import org.openstreetmap.josm.data.osm.Node;
     16import org.openstreetmap.josm.data.osm.Way;
    1517import org.openstreetmap.josm.gui.MainApplication;
    1618import org.openstreetmap.josm.gui.MapFrame;
     
    7173
    7274    /**
     75     * Several selected ways connected by common nodes are offset together, one result way per source way.
     76     */
     77    @Test
     78    void testMultipleSelectedWays() {
     79        Node a = new Node(LatLon.ZERO);
     80        Node b = new Node(new LatLon(0, 0.0001));
     81        Node c = new Node(new LatLon(0, 0.0002));
     82        Way w1 = new Way();
     83        w1.addNode(a);
     84        w1.addNode(b);
     85        Way w2 = new Way();
     86        w2.addNode(b);
     87        w2.addNode(c);
     88        for (Node n : new Node[] {a, b, c}) {
     89            this.dataSet.addPrimitive(n);
     90        }
     91        this.dataSet.addPrimitive(w1);
     92        this.dataSet.addPrimitive(w2);
     93        this.dataSet.setSelected(w1, w2);
     94        this.map.selectMapMode(mapMode);
     95        MapModeUtils.dragFromTo(new LatLon(0, 0.00005), new LatLon(0.00005, 0.00005));
     96        assertEquals(2, this.dataSet.getWays().size() - 2, "two parallel ways expected: " + this.dataSet.getWays());
     97        assertEquals(3 + 3 + 2 + 2, this.dataSet.allPrimitives().size());
     98    }
     99
     100    /**
     101     * The selection changed while in the mode (e.g. by Selection > Non-branching way sequences, after a first
     102     * parallel way has been created) is used as source.
     103     */
     104    @Test
     105    void testSelectionChangedInMode() {
     106        Node a = new Node(LatLon.ZERO);
     107        Node b = new Node(new LatLon(0, 0.0001));
     108        Node c = new Node(new LatLon(0, 0.0002));
     109        Way w1 = new Way();
     110        w1.addNode(a);
     111        w1.addNode(b);
     112        Way w2 = new Way();
     113        w2.addNode(b);
     114        w2.addNode(c);
     115        for (Node n : new Node[] {a, b, c}) {
     116            this.dataSet.addPrimitive(n);
     117        }
     118        this.dataSet.addPrimitive(w1);
     119        this.dataSet.addPrimitive(w2);
     120        this.dataSet.setSelected(w1);
     121        this.map.selectMapMode(mapMode);
     122        // first parallel of the single selected way
     123        MapModeUtils.dragFromTo(new LatLon(0, 0.00005), new LatLon(0.00005, 0.00005));
     124        assertEquals(3, this.dataSet.getWays().size());
     125        // now the selection is extended by other means, the next drag must use both ways
     126        this.dataSet.setSelected(w1, w2);
     127        MapModeUtils.dragFromTo(new LatLon(0, 0.00005), new LatLon(-0.00005, 0.00005));
     128        assertEquals(5, this.dataSet.getWays().size(), this.dataSet.getWays().toString());
     129    }
     130
     131    /**
    73132     * Unit test of {@link Mode} enum.
    74133     */
Note: See TracChangeset for help on using the changeset viewer.