@Test
public void testColorProperty() throws Exception {

  ColorPanel colorPanel = new ColorPanel();
  ColorProperty color = new ColorProperty(colorPanel);
  CountListener listener = new CountListener();
  color.addListener(listener);
  assertThat(color.get().isPresent()).isFalse();
  assertThat(listener.getCount()).isEqualTo(0);
  colorPanel.setSelectedColor(Color.RED);
  assertThat(color.get().isPresent()).isTrue();
  assertThat(color.getValue()).isEqualTo(Color.RED);
  // ColorPanel only fires its listener when the button is clicked, not when color is set
  // programmatically. Otherwise, this should have been true:
  // assertThat(listener.getCount()).isEqualTo(1);
  color.setValue(Color.BLUE);
  assertThat(colorPanel.getSelectedColor()).isEqualTo(Color.BLUE);
  assertThat(listener.getCount()).isEqualTo(1);
  color.clear();
  assertThat(colorPanel.getSelectedColor()).isNull();
  assertThat(listener.getCount()).isEqualTo(2);
}