Changeset 18207 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2021-09-11T17:00:13+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #21257 - sort tracks chronologically when writing GPX file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java

    r17845 r18207  
    323323        data.addTrack(track2);
    324324        assertEquals(3 * new LatLon(0, 0).greatCircleDistance(new LatLon(1, 1)), data.length(), 1);
    325 
     325    }
     326
     327    /**
     328     * Test method for {@link GpxData#getOrderedTracks()}.
     329     */
     330    @Test
     331    void testGetOrderedTracks() {
     332        assertTrue(data.getOrderedTracks().isEmpty());
     333
     334        WayPoint p1 = new WayPoint(LatLon.NORTH_POLE);
     335        WayPoint p2 = new WayPoint(LatLon.NORTH_POLE);
     336
     337        p1.setInstant(Instant.ofEpochMilli(100020));
     338        p2.setInstant(Instant.ofEpochMilli(200020));
     339
     340        data.addTrack(new GpxTrack(Arrays.asList(Arrays.asList(p2)), Collections.emptyMap()));
     341        data.addTrack(new GpxTrack(Arrays.asList(Arrays.asList(p1)), Collections.emptyMap()));
     342
     343        List<IGpxTrack> tracks = data.getOrderedTracks();
     344        assertEquals(2, tracks.size());
     345
     346        assertEquals(p1, tracks.get(0).getSegments().iterator().next().getWayPoints().iterator().next());
     347        assertEquals(p2, tracks.get(1).getSegments().iterator().next().getWayPoints().iterator().next());
    326348    }
    327349
Note: See TracChangeset for help on using the changeset viewer.