Changeset 9742 in josm for trunk/test


Ignore:
Timestamp:
2016-02-05T00:31:52+01:00 (9 years ago)
Author:
simon04
Message:

fix #12486 - Gpx/image correlation: allow sub-second offset

The textfield allows to input offsets in 1/1000s ("1.234" = 1234ms).
The seconds slider in the manual adjustment allows offsets of 1/10s.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImagesTest.java

    r9741 r9742  
    9999        assertEquals("123", CorrelateGpxWithImages.Offset.seconds(123).formatOffset());
    100100        assertEquals("-4242", CorrelateGpxWithImages.Offset.seconds(-4242).formatOffset());
     101        assertEquals("0.1", CorrelateGpxWithImages.Offset.milliseconds(100).formatOffset());
     102        assertEquals("0.120", CorrelateGpxWithImages.Offset.milliseconds(120).formatOffset());
     103        assertEquals("0.123", CorrelateGpxWithImages.Offset.milliseconds(123).formatOffset());
     104        assertEquals("1.2", CorrelateGpxWithImages.Offset.milliseconds(1200).formatOffset());
     105        assertEquals("1.234", CorrelateGpxWithImages.Offset.milliseconds(1234).formatOffset());
    101106    }
    102107
     
    107112        assertEquals(-4242L, CorrelateGpxWithImages.Offset.parseOffset("-4242").getSeconds());
    108113        assertEquals(0L, CorrelateGpxWithImages.Offset.parseOffset("-0").getSeconds());
     114        assertEquals(100L, CorrelateGpxWithImages.Offset.parseOffset("0.1").getMilliseconds());
     115        assertEquals(123L, CorrelateGpxWithImages.Offset.parseOffset("0.123").getMilliseconds());
     116        assertEquals(-42420L, CorrelateGpxWithImages.Offset.parseOffset("-42.42").getMilliseconds());
     117    }
     118
     119    @Test
     120    public void testSplitOutTimezone() throws Exception {
     121        assertEquals("+1:00", CorrelateGpxWithImages.Offset.seconds(3602).splitOutTimezone().a.formatTimezone());
     122        assertEquals("2", CorrelateGpxWithImages.Offset.seconds(3602).splitOutTimezone().b.formatOffset());
     123        assertEquals("-7:00", CorrelateGpxWithImages.Offset.seconds(-7 * 3600 + 123).splitOutTimezone().a.formatTimezone());
     124        assertEquals("123", CorrelateGpxWithImages.Offset.seconds(-7 * 3600 + 123).splitOutTimezone().b.formatOffset());
     125        assertEquals(1, CorrelateGpxWithImages.Offset.seconds(35 * 3600 + 421).getDayOffset());
     126        assertEquals(11 * 3600 + 421, CorrelateGpxWithImages.Offset.seconds(35 * 3600 + 421).withoutDayOffset().getSeconds());
     127        assertEquals("+11:00", CorrelateGpxWithImages.Offset.seconds(35 * 3600 + 421).splitOutTimezone().a.formatTimezone());
     128        assertEquals(86400 + 421, CorrelateGpxWithImages.Offset.seconds(35 * 3600 + 421).splitOutTimezone().b.getSeconds());
     129        assertEquals(421, CorrelateGpxWithImages.Offset.seconds(35 * 3600 + 421).withoutDayOffset().splitOutTimezone().b.getSeconds());
     130        assertEquals("+1:00", CorrelateGpxWithImages.Offset.milliseconds(3602987).splitOutTimezone().a.formatTimezone());
     131        assertEquals("2.987", CorrelateGpxWithImages.Offset.milliseconds(3602987).splitOutTimezone().b.formatOffset());
    109132    }
    110133}
Note: See TracChangeset for help on using the changeset viewer.