public void testMaliciousGetIcons() {
    Iterable<WWIcon> icons = createExampleIterable();

    IconLayer layer = new IconLayer();
    layer.addIcons(icons);

    Iterable<WWIcon> layerIcons = layer.getIcons();

    // Test that the returned list cannot be modified.
    try {
      if (layerIcons instanceof java.util.Collection) {
        java.util.Collection<WWIcon> collection = (java.util.Collection<WWIcon>) layerIcons;
        collection.clear();
      } else {
        java.util.Iterator<WWIcon> iter = layerIcons.iterator();
        while (iter.hasNext()) {
          iter.next();
          iter.remove();
        }
      }
    } catch (UnsupportedOperationException e) {
      e.printStackTrace();
    }

    // Test that the layer contents do not change, even if the returned list can be modified.
    assertEquals("", icons, layerIcons);
  }
  public void testMaliciousSetIcons() {
    // Create an Iterable with null elements.
    java.util.List<WWIcon> list = new java.util.ArrayList<WWIcon>();
    list.add(null);

    IconLayer layer =
        new IconLayer() {
          // Override to avoid View initialization issues.
          public boolean isLayerActive(DrawContext dc) {
            return true;
          }
        };
    layer.setIcons(list);

    DrawContext dc = new DrawContextImpl();
    dc.setModel(new BasicModel());
    dc.setView(new BasicOrbitView());

    try {
      // Test that the layer does not fail when the Iterable is used.
      layer.render(dc);
    } catch (NullPointerException e) {
      fail("Layer does not check for null elements in Iterable");
    }
  }
  public void testSetIcons() {
    Iterable<WWIcon> icons = createExampleIterable();

    IconLayer layer = new IconLayer();
    layer.setIcons(icons);

    // Test that the layer points to the Iterable.
    assertSame("", icons, layer.getIcons());
  }
  public void testAddIcons() {
    Iterable<WWIcon> icons = createExampleIterable();

    IconLayer layer = new IconLayer();
    layer.addIcons(icons);

    // Test that the layer contains the icons.
    assertEquals("", icons, layer.getIcons());
  }
  public void testRemoveAllIcons() {
    Iterable<WWIcon> icons = createExampleIterable();

    IconLayer layer = new IconLayer();
    layer.addIcons(icons);
    layer.removeAllIcons();

    // Test that the layer contains no icons.
    assertFalse("", layer.getIcons().iterator().hasNext());
  }
  public void testRemoveAllIconsFail() {
    Iterable<WWIcon> icons = createExampleIterable();

    IconLayer layer = new IconLayer();
    layer.setIcons(icons);

    try {
      // Expecting an IllegalStateException here.
      layer.removeAllIcons();
      fail("");
    } catch (IllegalStateException e) {
    }
  }
  public void testRemoveIconFail() {
    Iterable<WWIcon> icons = createExampleIterable();

    IconLayer layer = new IconLayer();
    layer.setIcons(icons);

    try {
      // Expecting an IllegalStateException here.
      layer.removeIcon(new UserFacingIcon("", Position.ZERO));
      fail("");
    } catch (IllegalStateException e) {
    }
  }
  /**
   * ********************************************************************************************************
   */
  public void testSetIconsClearsIcons() {
    Iterable<WWIcon> icons = createExampleIterable();

    IconLayer layer = new IconLayer();
    layer.addIcons(icons);
    layer.setIcons(icons);
    layer.setIcons(null);

    // Test that the layer does not point to the Iterable.
    assertNotSame("", icons, layer.getIcons());
    // Test that the layer contains no icons.
    assertFalse("", layer.getIcons().iterator().hasNext());
  }
  public void testSetIconsThenAddIcons() {
    Iterable<WWIcon> icons = createExampleIterable();

    IconLayer layer = new IconLayer();
    layer.setIcons(icons);
    layer.setIcons(null);
    layer.addIcons(icons);

    // Test that the layer does not point to the Iterable.
    assertNotSame("", icons, layer.getIcons());
    // Test that the layer contains the icons.
    assertEquals("", icons, layer.getIcons());
  }
    public AppFrame() {
      super(true, true, false);

      IconLayer layer = new IconLayer();
      layer.setPickEnabled(true);
      layer.setAllowBatchPicking(false);
      layer.setRegionCulling(true);

      UserFacingIcon icon =
          new UserFacingIcon(
              "src/images/32x32-icon-nasa.png",
              new Position(Angle.fromRadians(0), Angle.fromRadians(0), 0));
      icon.setSize(new Dimension(24, 24));
      layer.addIcon(icon);

      icon =
          new UserFacingIcon(
              "src/images/32x32-icon-nasa.png",
              new Position(Angle.fromRadians(0.1), Angle.fromRadians(0.0), 0));
      icon.setSize(new Dimension(24, 24));
      layer.addIcon(icon);

      icon =
          new UserFacingIcon(
              "src/images/32x32-icon-nasa.png",
              new Position(Angle.fromRadians(0.0), Angle.fromRadians(0.1), 0));
      icon.setSize(new Dimension(24, 24));
      layer.addIcon(icon);

      icon =
          new UserFacingIcon(
              "src/images/32x32-icon-nasa.png",
              new Position(Angle.fromRadians(0.1), Angle.fromRadians(0.1), 0));
      icon.setSize(new Dimension(24, 24));
      layer.addIcon(icon);

      icon =
          new UserFacingIcon(
              "src/images/32x32-icon-nasa.png",
              new Position(Angle.fromRadians(0), Angle.fromDegrees(180), 0));
      icon.setSize(new Dimension(24, 24));
      layer.addIcon(icon);

      ApplicationTemplate.insertAfterPlacenames(this.getWwd(), layer);

      this.getWwd()
          .addSelectListener(
              new SelectListener() {
                @Override
                public void selected(SelectEvent event) {
                  if (event.getEventAction().equals(SelectEvent.ROLLOVER)) {
                    PickedObjectList pol = event.getObjects();
                    System.out.println(" Picked Objects Size " + pol.size());
                    for (PickedObject po : pol) {
                      System.out.println(
                          " Class "
                              + po.getObject().getClass().getName()
                              + "  isTerrian="
                              + po.isTerrain());
                    }
                  }
                }
              });
      this.getWwd().getSceneController().setDeepPickEnabled(true);
    }