mockLeaf.deleteObserver(leaf3D);
assertEquals(0, mockLeaf.countObservers());
}
public void testAppearance() {
mockLeaf.setEfficiency(new Percent(80));
BasicTreeLeaf3D leaf3D = new BasicTreeLeaf3D(mockUniverse3D, leaf3DState, mockLeaf);
CompilerHelper.compile(leaf3D.getBranchGroup());
Shape3D leafShape3D = (Shape3D) leaf3D.getBranchGroup().getChild(0);
Color3f expectedColor = new Color3f(ColorConstants.brownYellow);
expectedColor.interpolate(ColorConstants.green, 0.8f);
ColorTestHelper.testColorFromMaterial(leafShape3D.getAppearance(), expectedColor, new Color3f(0.05f, 0.05f,
0.05f), new Color3f(0.15f, 0.15f, 0.15f));
// check the leaves are not culled (transparent) when seen from behind
assertEquals(PolygonAttributes.CULL_NONE, leafShape3D.getAppearance().getPolygonAttributes().getCullFace());
mockLeaf.setEfficiency(new Percent(75));
leaf3D.update(mockLeaf, LeafUpdateCode.efficiency);
// check that the color has changed as expected
expectedColor = new Color3f(ColorConstants.brownYellow);
expectedColor.interpolate(ColorConstants.green, 0.75f);
ColorTestHelper.testColorFromMaterial(leafShape3D.getAppearance(), expectedColor, new Color3f(0.05f, 0.05f,
0.05f), new Color3f(0.15f, 0.15f, 0.15f));
mockLeaf.setEfficiency(new Percent(60));
leaf3D.update(mockLeaf, null);
// check that the color has NOT changed as expected, because the update code is not the appropriate one
expectedColor = new Color3f(ColorConstants.brownYellow);
expectedColor.interpolate(ColorConstants.green, 0.75f); // 75%, not 60%