Changeset 31989 in osm for applications/editors/josm


Ignore:
Timestamp:
2016-01-16T17:47:43+01:00 (9 years ago)
Author:
floscher
Message:

[mapillary] Add more tests for MapillaryLayer

Location:
applications/editors/josm/plugins/mapillary
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java

    r31987 r31989  
    7676   * @param image  The image to be added.
    7777   * @param update Whether the map must be updated or not.
     78   * @throws NullPointerException if parameter <code>image</code> is <code>null</code>
    7879   */
    7980  public synchronized void add(MapillaryAbstractImage image, boolean update) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java

    r31985 r31989  
    246246      img.setVisible(visible);
    247247    }
    248     MapillaryFilterDialog.getInstance().refresh();
     248    if (Main.map != null) {
     249      MapillaryFilterDialog.getInstance().refresh();
     250    }
    249251  }
    250252
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillaryLayerTest.java

    r31797 r31989  
    33import static org.junit.Assert.assertEquals;
    44import static org.junit.Assert.assertFalse;
     5import static org.junit.Assert.assertTrue;
     6
     7import java.io.File;
    58
    69import org.junit.Test;
     
    2629    MapillaryLayer.getInstance().mergeFrom(dummyLayer);
    2730  }
     31
     32  @Test
     33  public void testSetVisible() {
     34    MapillaryLayer.getInstance().getData().add(new MapillaryImportedImage(0.0, 0.0, 0.0, new File("")));
     35    MapillaryLayer.getInstance().getData().add(new MapillaryImportedImage(0.0, 0.0, 0.0, new File("")));
     36    MapillaryImportedImage invisibleImage = new MapillaryImportedImage(0.0, 0.0, 0.0, new File(""));
     37    invisibleImage.setVisible(false);
     38    MapillaryLayer.getInstance().getData().add(invisibleImage);
     39
     40    MapillaryLayer.getInstance().setVisible(false);
     41    for (MapillaryAbstractImage img : MapillaryLayer.getInstance().getData().getImages()) {
     42      assertEquals(false, img.isVisible());
     43    }
     44
     45
     46    MapillaryLayer.getInstance().setVisible(true);
     47    for (MapillaryAbstractImage img : MapillaryLayer.getInstance().getData().getImages()) {
     48      assertEquals(true, img.isVisible());
     49    }
     50  }
     51
     52  @Test
     53  public void testGetInfoComponent() {
     54    Object comp = MapillaryLayer.getInstance().getInfoComponent();
     55    assertTrue(comp instanceof String);
     56    assertTrue(((String)comp).length() >= 9);
     57  }
     58
     59  @Test
     60  public void testClearInstance() {
     61    MapillaryLayer.getInstance();
     62    assertTrue(MapillaryLayer.hasInstance());
     63    MapillaryLayer.clearInstance();
     64    assertFalse(MapillaryLayer.hasInstance());
     65    MapillaryLayer.getInstance();
     66    assertTrue(MapillaryLayer.hasInstance());
     67  }
    2868}
Note: See TracChangeset for help on using the changeset viewer.