changeset 5853:20724ec5e62e

[TEST ONLY] Test for RT-34566, which happened to be fixed by RT-34573.
author jgiles
date Fri, 29 Nov 2013 08:25:49 +1300
parents 24f2584b90eb
children cc089c819470
files modules/controls/src/test/java/javafx/scene/control/ComboBoxTest.java
diffstat 1 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/test/java/javafx/scene/control/ComboBoxTest.java	Fri Nov 29 08:16:34 2013 +1300
+++ b/modules/controls/src/test/java/javafx/scene/control/ComboBoxTest.java	Fri Nov 29 08:25:49 2013 +1300
@@ -1125,4 +1125,38 @@
         assertTrue(comboBox.getButtonCell().getText().isEmpty());
         assertEquals(-1, comboBox.getButtonCell().getIndex());
     }
+
+    @Test public void test_rt34566() {
+        final ComboBox<String> comboBox = new ComboBox<>();
+
+        final ListCell<String> customCell = new ListCell<String>() {
+            @Override protected void updateItem(String item, boolean empty) {
+                super.updateItem(item, empty);
+                setText(item);
+            }
+        };
+        comboBox.setButtonCell(customCell);
+
+        new StageLoader(comboBox);
+
+        comboBox.setItems(FXCollections.observableArrayList("A","B","C","D"));
+
+        PseudoClass empty = PseudoClass.getPseudoClass("empty");
+
+        comboBox.setValue("B");
+        assertEquals("B", comboBox.getButtonCell().getText());
+        assertEquals(1, comboBox.getButtonCell().getIndex());
+        assertFalse(customCell.getPseudoClassStates().contains(empty));
+
+        comboBox.setValue(null);
+        Toolkit.getToolkit().firePulse();
+        assertTrue(comboBox.getButtonCell().getText().isEmpty());
+        assertEquals(-1, comboBox.getButtonCell().getIndex());
+        assertTrue(customCell.getPseudoClassStates().contains(empty));
+
+        comboBox.setValue("A");
+        assertEquals("A", comboBox.getButtonCell().getText());
+        assertEquals(0, comboBox.getButtonCell().getIndex());
+        assertFalse(customCell.getPseudoClassStates().contains(empty));
+    }
 }