Changeset 6992 in josm for trunk/test


Ignore:
Timestamp:
2014-04-22T01:06:55+02:00 (6 years ago)
Author:
Don-vip
Message:

cleanup/refactor of NavigatableComponent

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/SystemOfMeasurementTest.java

    r6881 r6992  
    1010import org.junit.Test;
    1111import org.openstreetmap.josm.Main;
    12 import org.openstreetmap.josm.gui.NavigatableComponent.SystemOfMeasurement;
     12import org.openstreetmap.josm.data.SystemOfMeasurement;
    1313
    1414/**
     
    3131    public void testGetDistText() {
    3232
    33         assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(-1));
    34         assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(-0.99));
    35         assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(-0));
    36         assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(0));
     33        assertEquals("< 0.01 m", SystemOfMeasurement.METRIC.getDistText(-1));
     34        assertEquals("< 0.01 m", SystemOfMeasurement.METRIC.getDistText(-0.99));
     35        assertEquals("< 0.01 m", SystemOfMeasurement.METRIC.getDistText(-0));
     36        assertEquals("< 0.01 m", SystemOfMeasurement.METRIC.getDistText(0));
    3737
    38         assertEquals("0.01 m", NavigatableComponent.METRIC_SOM.getDistText(0.01));
     38        assertEquals("0.01 m", SystemOfMeasurement.METRIC.getDistText(0.01));
    3939
    40         assertEquals("0.99 m", NavigatableComponent.METRIC_SOM.getDistText(0.99));
    41         assertEquals("1.00 m", NavigatableComponent.METRIC_SOM.getDistText(1.0));
    42         assertEquals("1.01 m", NavigatableComponent.METRIC_SOM.getDistText(1.01));
     40        assertEquals("0.99 m", SystemOfMeasurement.METRIC.getDistText(0.99));
     41        assertEquals("1.00 m", SystemOfMeasurement.METRIC.getDistText(1.0));
     42        assertEquals("1.01 m", SystemOfMeasurement.METRIC.getDistText(1.01));
    4343
    44         assertEquals("9.99 m", NavigatableComponent.METRIC_SOM.getDistText(9.99));
    45         assertEquals("10.0 m", NavigatableComponent.METRIC_SOM.getDistText(10.0));
    46         assertEquals("10.0 m", NavigatableComponent.METRIC_SOM.getDistText(10.01));
    47         assertEquals("10.0 m", NavigatableComponent.METRIC_SOM.getDistText(10.049));
    48         assertEquals("10.1 m", NavigatableComponent.METRIC_SOM.getDistText(10.050));
    49         assertEquals("10.1 m", NavigatableComponent.METRIC_SOM.getDistText(10.051));
     44        assertEquals("9.99 m", SystemOfMeasurement.METRIC.getDistText(9.99));
     45        assertEquals("10.0 m", SystemOfMeasurement.METRIC.getDistText(10.0));
     46        assertEquals("10.0 m", SystemOfMeasurement.METRIC.getDistText(10.01));
     47        assertEquals("10.0 m", SystemOfMeasurement.METRIC.getDistText(10.049));
     48        assertEquals("10.1 m", SystemOfMeasurement.METRIC.getDistText(10.050));
     49        assertEquals("10.1 m", SystemOfMeasurement.METRIC.getDistText(10.051));
    5050
    51         assertEquals("100.0 m", NavigatableComponent.METRIC_SOM.getDistText(99.99));
    52         assertEquals("100.0 m", NavigatableComponent.METRIC_SOM.getDistText(100.0));
    53         assertEquals("100.0 m", NavigatableComponent.METRIC_SOM.getDistText(100.01));
     51        assertEquals("100.0 m", SystemOfMeasurement.METRIC.getDistText(99.99));
     52        assertEquals("100.0 m", SystemOfMeasurement.METRIC.getDistText(100.0));
     53        assertEquals("100.0 m", SystemOfMeasurement.METRIC.getDistText(100.01));
    5454
    55         assertEquals("1000.0 m", NavigatableComponent.METRIC_SOM.getDistText(999.99)); // TODO ? 1.00 km should be better
    56         assertEquals("1000.0 m", NavigatableComponent.METRIC_SOM.getDistText(1000.0)); // TODO ? 1.00 km should be better
    57         assertEquals("1.00 km", NavigatableComponent.METRIC_SOM.getDistText(1000.01));
     55        assertEquals("1000.0 m", SystemOfMeasurement.METRIC.getDistText(999.99)); // TODO ? 1.00 km should be better
     56        assertEquals("1000.0 m", SystemOfMeasurement.METRIC.getDistText(1000.0)); // TODO ? 1.00 km should be better
     57        assertEquals("1.00 km", SystemOfMeasurement.METRIC.getDistText(1000.01));
    5858
    59         assertEquals("10.00 km", NavigatableComponent.METRIC_SOM.getDistText(9999.99)); // TODO ? 10.0 km should be better
    60         assertEquals("10.0 km", NavigatableComponent.METRIC_SOM.getDistText(10000.0));
    61         assertEquals("10.0 km", NavigatableComponent.METRIC_SOM.getDistText(10000.01));
     59        assertEquals("10.00 km", SystemOfMeasurement.METRIC.getDistText(9999.99)); // TODO ? 10.0 km should be better
     60        assertEquals("10.0 km", SystemOfMeasurement.METRIC.getDistText(10000.0));
     61        assertEquals("10.0 km", SystemOfMeasurement.METRIC.getDistText(10000.01));
    6262
    63         assertEquals("100.0 km", NavigatableComponent.METRIC_SOM.getDistText(99999.99));
    64         assertEquals("100.0 km", NavigatableComponent.METRIC_SOM.getDistText(100000.0));
    65         assertEquals("100.0 km", NavigatableComponent.METRIC_SOM.getDistText(100000.01));
     63        assertEquals("100.0 km", SystemOfMeasurement.METRIC.getDistText(99999.99));
     64        assertEquals("100.0 km", SystemOfMeasurement.METRIC.getDistText(100000.0));
     65        assertEquals("100.0 km", SystemOfMeasurement.METRIC.getDistText(100000.01));
    6666    }
    6767
     
    7272    public void testGetDistTextLocalized() {
    7373        final DecimalFormat format = new DecimalFormat("0.000", DecimalFormatSymbols.getInstance(Locale.GERMAN));
    74         assertEquals("0,001 m", NavigatableComponent.METRIC_SOM.getDistText(0.001, format, 1e-6));
    75         assertEquals("< 0,010 m", NavigatableComponent.METRIC_SOM.getDistText(0.001, format, 0.01));
    76         assertEquals("10,051 m", NavigatableComponent.METRIC_SOM.getDistText(10.0514, format, 0.01));
    77         assertEquals("10,052 m", NavigatableComponent.METRIC_SOM.getDistText(10.0515, format, 0.01));
    78         assertEquals("100,000 km", NavigatableComponent.METRIC_SOM.getDistText(100000.0, format, 0.01));
     74        assertEquals("0,001 m", SystemOfMeasurement.METRIC.getDistText(0.001, format, 1e-6));
     75        assertEquals("< 0,010 m", SystemOfMeasurement.METRIC.getDistText(0.001, format, 0.01));
     76        assertEquals("10,051 m", SystemOfMeasurement.METRIC.getDistText(10.0514, format, 0.01));
     77        assertEquals("10,052 m", SystemOfMeasurement.METRIC.getDistText(10.0515, format, 0.01));
     78        assertEquals("100,000 km", SystemOfMeasurement.METRIC.getDistText(100000.0, format, 0.01));
    7979    }
    8080
     
    8484    @Test
    8585    public void testGetAreaText() {
    86         assertEquals("< 0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(-1));
    87         assertEquals("< 0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(-0.99));
    88         assertEquals("< 0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(-0));
    89         assertEquals("< 0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(0));
     86        assertEquals("< 0.01 m²", SystemOfMeasurement.METRIC.getAreaText(-1));
     87        assertEquals("< 0.01 m²", SystemOfMeasurement.METRIC.getAreaText(-0.99));
     88        assertEquals("< 0.01 m²", SystemOfMeasurement.METRIC.getAreaText(-0));
     89        assertEquals("< 0.01 m²", SystemOfMeasurement.METRIC.getAreaText(0));
    9090
    91         assertEquals("0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(0.01));
     91        assertEquals("0.01 m²", SystemOfMeasurement.METRIC.getAreaText(0.01));
    9292
    93         assertEquals("0.99 m²", NavigatableComponent.METRIC_SOM.getAreaText(0.99));
    94         assertEquals("1.00 m²", NavigatableComponent.METRIC_SOM.getAreaText(1.0));
    95         assertEquals("1.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(1.01));
     93        assertEquals("0.99 m²", SystemOfMeasurement.METRIC.getAreaText(0.99));
     94        assertEquals("1.00 m²", SystemOfMeasurement.METRIC.getAreaText(1.0));
     95        assertEquals("1.01 m²", SystemOfMeasurement.METRIC.getAreaText(1.01));
    9696
    97         assertEquals("9.99 m²", NavigatableComponent.METRIC_SOM.getAreaText(9.99));
    98         assertEquals("10.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(10.0));
    99         assertEquals("10.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(10.01));
    100         assertEquals("10.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(10.049));
    101         assertEquals("10.1 m²", NavigatableComponent.METRIC_SOM.getAreaText(10.050));
    102         assertEquals("10.1 m²", NavigatableComponent.METRIC_SOM.getAreaText(10.051));
     97        assertEquals("9.99 m²", SystemOfMeasurement.METRIC.getAreaText(9.99));
     98        assertEquals("10.0 m²", SystemOfMeasurement.METRIC.getAreaText(10.0));
     99        assertEquals("10.0 m²", SystemOfMeasurement.METRIC.getAreaText(10.01));
     100        assertEquals("10.0 m²", SystemOfMeasurement.METRIC.getAreaText(10.049));
     101        assertEquals("10.1 m²", SystemOfMeasurement.METRIC.getAreaText(10.050));
     102        assertEquals("10.1 m²", SystemOfMeasurement.METRIC.getAreaText(10.051));
    103103
    104         assertEquals("100.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(99.99));
    105         assertEquals("100.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(100.0));
    106         assertEquals("100.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(100.01));
     104        assertEquals("100.0 m²", SystemOfMeasurement.METRIC.getAreaText(99.99));
     105        assertEquals("100.0 m²", SystemOfMeasurement.METRIC.getAreaText(100.0));
     106        assertEquals("100.0 m²", SystemOfMeasurement.METRIC.getAreaText(100.01));
    107107
    108         assertEquals("1000.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(999.99));
    109         assertEquals("1000.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(1000.0));
    110         assertEquals("1000.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(1000.01));
     108        assertEquals("1000.0 m²", SystemOfMeasurement.METRIC.getAreaText(999.99));
     109        assertEquals("1000.0 m²", SystemOfMeasurement.METRIC.getAreaText(1000.0));
     110        assertEquals("1000.0 m²", SystemOfMeasurement.METRIC.getAreaText(1000.01));
    111111
    112         assertEquals("10000.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(9999.99)); // TODO ? 1.00 ha should be better
    113         assertEquals("10000.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(10000.0)); // TODO ? 1.00 ha should be better
    114         assertEquals("1.00 ha", NavigatableComponent.METRIC_SOM.getAreaText(10000.01));
     112        assertEquals("10000.0 m²", SystemOfMeasurement.METRIC.getAreaText(9999.99)); // TODO ? 1.00 ha should be better
     113        assertEquals("10000.0 m²", SystemOfMeasurement.METRIC.getAreaText(10000.0)); // TODO ? 1.00 ha should be better
     114        assertEquals("1.00 ha", SystemOfMeasurement.METRIC.getAreaText(10000.01));
    115115
    116         assertEquals("10.0 ha", NavigatableComponent.METRIC_SOM.getAreaText(99999.99));
    117         assertEquals("10.0 ha", NavigatableComponent.METRIC_SOM.getAreaText(100000.0));
    118         assertEquals("10.0 ha", NavigatableComponent.METRIC_SOM.getAreaText(100000.01));
     116        assertEquals("10.0 ha", SystemOfMeasurement.METRIC.getAreaText(99999.99));
     117        assertEquals("10.0 ha", SystemOfMeasurement.METRIC.getAreaText(100000.0));
     118        assertEquals("10.0 ha", SystemOfMeasurement.METRIC.getAreaText(100000.01));
    119119
    120         assertEquals("100.0 ha", NavigatableComponent.METRIC_SOM.getAreaText(999999.99)); // TODO ? 1.00 km² should be better
    121         assertEquals("1.00 km²", NavigatableComponent.METRIC_SOM.getAreaText(1000000.0));
    122         assertEquals("1.00 km²", NavigatableComponent.METRIC_SOM.getAreaText(1000000.01));
     120        assertEquals("100.0 ha", SystemOfMeasurement.METRIC.getAreaText(999999.99)); // TODO ? 1.00 km² should be better
     121        assertEquals("1.00 km²", SystemOfMeasurement.METRIC.getAreaText(1000000.0));
     122        assertEquals("1.00 km²", SystemOfMeasurement.METRIC.getAreaText(1000000.01));
    123123
    124         assertEquals("10.0 km²", NavigatableComponent.METRIC_SOM.getAreaText(9999999.99));
    125         assertEquals("10.0 km²", NavigatableComponent.METRIC_SOM.getAreaText(10000000.0));
    126         assertEquals("10.0 km²", NavigatableComponent.METRIC_SOM.getAreaText(10000000.01));
     124        assertEquals("10.0 km²", SystemOfMeasurement.METRIC.getAreaText(9999999.99));
     125        assertEquals("10.0 km²", SystemOfMeasurement.METRIC.getAreaText(10000000.0));
     126        assertEquals("10.0 km²", SystemOfMeasurement.METRIC.getAreaText(10000000.01));
    127127    }
    128128}
Note: See TracChangeset for help on using the changeset viewer.