Ignore:
Timestamp:
2020-08-12T22:17:36+02:00 (4 years ago)
Author:
simon04
Message:

fix #19633 - Route relations with split start do not show links as expected in the relation editor (patch by matthijskooijman)

Location:
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java

    r16438 r16886  
    5959    }
    6060
     61    // This cluster of tests checks whether these relations are sorted
     62    // as expected, so these relations are of course not sorted in the
     63    // data file.
     64
    6165    @Test
    6266    public void testGeneric() {
     
    7983        Assert.assertArrayEquals(new String[]{"t2w1", "t2w2", "t2n1", "t2n2", "t2n3", "t2n4", "playground", "tree"}, actual);
    8084    }
     85
     86    // The following cluster of tests does the same, but with various
     87    // configurations involving split / dual carriageway routes (i.e.
     88    // containing members with role=forward or role=backward). Again,
     89    // these are intentionally not already sorted.
     90
     91    @Test
     92    public void testThreeLoopsEndsLoop() {
     93        Relation relation = getRelation("three-loops-ends-loop");
     94        // Check the first way before sorting, otherwise the sorter
     95        // might pick a different loop starting point than expected below
     96        Assert.assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name"));
     97
     98        String[] actual = getNames(sorter.sortMembers(relation.getMembers()));
     99        Assert.assertArrayEquals(new String[]{
     100            "t5w1", "t5w2a", "t5w3a", "t5w4a", "t5w2b", "t5w3b", "t5w4b",
     101            "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b",
     102            "t5w9a", "t5w10a", "t5w11a", "t5w9b", "t5w10b", "t5w11b",
     103            "t5w12", "t5w13",
     104        }, actual);
     105    }
     106
     107    @Test
     108    public void testThreeLoopsEndsWay() {
     109        Relation relation = getRelation("three-loops-ends-way");
     110        // Check the first way before sorting, otherwise the sorter
     111        // might sort in reverse compared to what is expected below
     112        Assert.assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name"));
     113
     114        String[] actual = getNames(sorter.sortMembers(relation.getMembers()));
     115        Assert.assertArrayEquals(new String[]{
     116            "t5w1", "t5w2a", "t5w3a", "t5w4a", "t5w2b", "t5w3b", "t5w4b",
     117            "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b",
     118            "t5w9a", "t5w10a", "t5w11a", "t5w9b", "t5w10b", "t5w11b",
     119            "t5w12",
     120        }, actual);
     121    }
     122
     123    @Test
     124    public void testThreeLoopsEndsNode() {
     125        Relation relation = getRelation("three-loops-ends-node");
     126        String[] actual = getNames(sorter.sortMembers(relation.getMembers()));
     127        Assert.assertArrayEquals(new String[]{
     128            "t5w4a", "t5w3a", "t5w2a", "t5w2b", "t5w3b", "t5w4b",
     129            "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b",
     130            "t5w9a", "t5w10a", "t5w11a", "t5w11b", "t5w10b", "t5w9b",
     131        }, actual);
     132    }
     133
     134    @Test
     135    public void testOneLoopEndsSplit() {
     136        Relation relation = getRelation("one-loop-ends-split");
     137        String[] actual = getNames(sorter.sortMembers(relation.getMembers()));
     138        Assert.assertArrayEquals(new String[]{
     139            "t5w3a", "t5w4a", "t5w3b", "t5w4b",
     140            "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b",
     141            "t5w9a", "t5w10a", "t5w9b", "t5w10b",
     142        }, actual);
     143    }
     144
     145    @Test
     146    public void testNoLoopEndsSplit() {
     147        Relation relation = getRelation("no-loop-ends-split");
     148        // TODO: This is not yet sorted properly, so this route is
     149        // presorted in the data file, making this a bit of a dummy test
     150        // for now.
     151        String[] actual = getNames(relation.getMembers());
     152        Assert.assertArrayEquals(new String[]{
     153            "t5w7a", "t5w8a", "t5w7b", "t5w8b",
     154            "t5w9a", "t5w10a", "t5w9b", "t5w10b",
     155        }, actual);
     156    }
     157
     158    @Test
     159    public void testIncompleteLoops() {
     160        Relation relation = getRelation("incomplete-loops");
     161        // TODO: This is not yet sorted perfectly (might not be possible)
     162        String[] actual = getNames(sorter.sortMembers(relation.getMembers()));
     163        Assert.assertArrayEquals(new String[]{
     164            "t5w1", "t5w2a", "t5w3a", "t5w4a", "t5w2b", "t5w3b",
     165            "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w9a", "t5w10a", "t5w11a", "t5w6b", "t5w7b",
     166            "t5w12", "t5w11b", "t5w10b", "t5w9b",
     167        }, actual);
     168    }
     169
     170    @Test
     171    public void testParallelOneWay() {
     172        Relation relation = getRelation("parallel-oneway");
     173        // TODO: This is not always sorted properly, only when the right
     174        // way is already at the top, so check that
     175        Assert.assertEquals("t6w1a", relation.getMembers().get(0).getMember().get("name"));
     176
     177        String[] actual = getNames(sorter.sortMembers(relation.getMembers()));
     178        Assert.assertArrayEquals(new String[]{
     179            "t6w1a", "t6w2a", "t6w3a",
     180            "t6w1b", "t6w2b", "t6w3b",
     181        }, actual);
     182    }
    81183}
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java

    r16438 r16886  
    105105    }
    106106
     107    // This cluster of tests checks the rendering before and after
     108    // sorting of a few relations. Initially, these relations are
     109    // intentionally not sorted to ensure the sorting has some work.
     110
    107111    @Test
    108112    public void testGeneric() {
     
    130134        //TODO Sorting doesn't work well in this case
    131135        actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers())));
    132         Assert.assertEquals("[BACKWARD, BACKWARD, BACKWARD, FPH FORWARD, FPH FORWARD, FPH FORWARD, FPH FORWARD]", actual);
     136        Assert.assertEquals("[BACKWARD, BACKWARD, BACKWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, BPT BACKWARD]", actual);
     137    }
     138
     139    // The following cluster of tests checks various configurations
     140    // involving split / dual carriageway routes (i.e. containing
     141    // members with role=forward or role=backward). Again, these are
     142    // intentionally not sorted.
     143
     144    @Test
     145    public void testThreeLoopsEndsLoop() {
     146        Relation relation = getRelation("three-loops-ends-loop");
     147        // Check the first way before sorting, otherwise the sorter
     148        // might pick a different loop starting point than expected below
     149        Assert.assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name"));
     150        String actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers())));
     151        String expected = "[" +
     152            "L FORWARD, LFPH FORWARD, LFP FORWARD, LFP FORWARD, LBP BACKWARD, LBP BACKWARD, LBPT BACKWARD, " +
     153            "L FORWARD, LFPH FORWARD, LFP FORWARD, LFP FORWARD, LBP BACKWARD, LBP BACKWARD, LBPT BACKWARD, " +
     154            "LFPH FORWARD, LFP FORWARD, LFP FORWARD, LBP BACKWARD, LBP BACKWARD, LBPT BACKWARD, " +
     155            "L FORWARD, L FORWARD" +
     156        "]";
     157        Assert.assertEquals(expected, actual);
     158    }
     159
     160    @Test
     161    public void testThreeLoopsEndsWay() {
     162        Relation relation = getRelation("three-loops-ends-way");
     163        // Check the first way before sorting, otherwise the sorter
     164        // might sort in reverse compared to what is expected below
     165        Assert.assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name"));
     166        String actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers())));
     167        String expected = "[" +
     168            "FORWARD, FPH FORWARD, FP FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, BPT BACKWARD, " +
     169            "FORWARD, FPH FORWARD, FP FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, BPT BACKWARD, " +
     170            "FPH FORWARD, FP FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, BPT BACKWARD, " +
     171            "FORWARD" +
     172        "]";
     173        Assert.assertEquals(expected, actual);
     174    }
     175
     176    @Test
     177    public void testThreeLoopsEndsNode() {
     178        Relation relation = getRelation("three-loops-ends-node");
     179        String actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers())));
     180        String expected = "[" +
     181            "FPH FORWARD, BP BACKWARD, BP BACKWARD, BP BACKWARD, BP BACKWARD, BPT BACKWARD, " +
     182            "FORWARD, FPH FORWARD, FP FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, BPT BACKWARD, " +
     183            "FPH FORWARD, FP FORWARD, FP FORWARD, FP FORWARD, FP FORWARD, BPT BACKWARD" +
     184        "]";
     185        Assert.assertEquals(expected, actual);
     186    }
     187
     188    @Test
     189    public void testOneLoopEndsSplit() {
     190        Relation relation = getRelation("one-loop-ends-split");
     191        String actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers())));
     192        String expected = "[" +
     193            "FP FORWARD, FP FORWARD, BP BACKWARD, BPT BACKWARD, " +
     194            "FORWARD, FPH FORWARD, FP FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, BPT BACKWARD, " +
     195            "FPH FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD" +
     196        "]";
     197        Assert.assertEquals(expected, actual);
     198    }
     199
     200    @Test
     201    public void testNoLoopEndsSplit() {
     202        Relation relation = getRelation("no-loop-ends-split");
     203        // TODO: This is not yet sorted properly, so this route is
     204        // presorted in the data file
     205        String actual = getConnections(wayConnectionTypeCalculator.updateLinks(relation.getMembers()));
     206        String expected = "[" +
     207            "FP FORWARD, FP FORWARD, BP BACKWARD, BPT BACKWARD, " +
     208            "FPH FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD" +
     209        "]";
     210        Assert.assertEquals(expected, actual);
     211    }
     212
     213    @Test
     214    public void testIncompleteLoops() {
     215        Relation relation = getRelation("incomplete-loops");
     216        // TODO: This is not yet sorted perfectly (might not be possible)
     217        String actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers())));
     218        String expected = "[" +
     219            "FORWARD, FPH FORWARD, FP FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, " +
     220            "FORWARD, FPH FORWARD, FP FORWARD, FP FORWARD, FP FORWARD, FP FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, " +
     221            "BACKWARD, FPH FORWARD, FP FORWARD, FP FORWARD" +
     222        "]";
     223        Assert.assertEquals(expected, actual);
     224    }
     225
     226    @Test
     227    public void testParallelOneWay() {
     228        Relation relation = getRelation("parallel-oneway");
     229        // TODO: This is not always sorted properly, only when the right
     230        // way is already at the top, so check that
     231        Assert.assertEquals("t6w1a", relation.getMembers().get(0).getMember().get("name"));
     232        String actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers())));
     233        String expected = "[" +
     234            "FP FORWARD, FP FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, BP BACKWARD" +
     235        "]";
     236        Assert.assertEquals(expected, actual);
    133237    }
    134238
Note: See TracChangeset for help on using the changeset viewer.