< prev index next >

modules/controls/src/test/java/test/javafx/scene/control/LabelTest.java

Print this page

        

*** 23,32 **** --- 23,33 ---- * questions. */ package test.javafx.scene.control; + import com.sun.javafx.scene.NodeHelper; import javafx.css.CssMetaData; import static test.com.sun.javafx.scene.control.infrastructure.ControlTestUtils.*; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull;
*** 169,272 **** // TODO on the showMnemonics of its labelFor, but since we do, I need // TODO to test it to make sure things get hooked up and unhooked @Test public void showMnemonicsHasNoListenersOnTextFieldByDefault() { // This is a sanity check test, so the following tests make sense TextField textField = new TextField(); ! assertEquals(0, getListenerCount(textField.impl_showMnemonicsProperty())); } @Test public void settingLabelForShouldAddListenerToShowMnemonics() { TextField textField = new TextField(); label.setLabelFor(textField); ! assertEquals(1, getListenerCount(textField.impl_showMnemonicsProperty())); } @Test public void settingLabelForShouldAddListenerToShowMnemonics_SetThroughProperty() { TextField textField = new TextField(); label.labelForProperty().set(textField); ! assertEquals(1, getListenerCount(textField.impl_showMnemonicsProperty())); } @Test public void settingLabelForShouldAddListenerToShowMnemonics_WhenBound() { TextField textField = new TextField(); ObjectProperty<TextField> other = new SimpleObjectProperty<TextField>(textField); label.labelForProperty().bind(other); ! assertEquals(1, getListenerCount(textField.impl_showMnemonicsProperty())); } @Test public void clearingLabelForShouldRemoveListenerFromShowMnemonics() { TextField textField = new TextField(); label.setLabelFor(textField); label.setLabelFor(null); ! assertEquals(0, getListenerCount(textField.impl_showMnemonicsProperty())); } @Test public void clearingLabelForShouldRemoveListenerFromShowMnemonics_SetThroughProperty() { TextField textField = new TextField(); label.labelForProperty().set(textField); label.labelForProperty().set(null); ! assertEquals(0, getListenerCount(textField.impl_showMnemonicsProperty())); } @Test public void clearingLabelForShouldRemoveListenerFromShowMnemonics_WhenBound() { TextField textField = new TextField(); ObjectProperty<TextField> other = new SimpleObjectProperty<TextField>(textField); label.labelForProperty().bind(other); other.set(null); ! assertEquals(0, getListenerCount(textField.impl_showMnemonicsProperty())); } @Test public void swappingLabelForShouldAddAndRemoveListenerFromShowMnemonics() { TextField a = new TextField(); TextField b = new TextField(); label.setLabelFor(a); label.setLabelFor(b); ! assertEquals(0, getListenerCount(a.impl_showMnemonicsProperty())); ! assertEquals(1, getListenerCount(b.impl_showMnemonicsProperty())); } @Test public void swappingLabelForShouldAddAndRemoveListenerFromShowMnemonics_SetThroughProperty() { TextField a = new TextField(); TextField b = new TextField(); label.labelForProperty().set(a); label.labelForProperty().set(b); ! assertEquals(0, getListenerCount(a.impl_showMnemonicsProperty())); ! assertEquals(1, getListenerCount(b.impl_showMnemonicsProperty())); } @Test public void swappingLabelForShouldAddAndRemoveListenerFromShowMnemonics_WhenBound() { TextField a = new TextField(); TextField b = new TextField(); ObjectProperty<TextField> other = new SimpleObjectProperty<TextField>(a); label.labelForProperty().bind(other); other.set(b); ! assertEquals(0, getListenerCount(a.impl_showMnemonicsProperty())); ! assertEquals(1, getListenerCount(b.impl_showMnemonicsProperty())); } @Test public void changingShowMnemonicsOnLabelForUpdatesStateForLabel() { TextField textField = new TextField(); label.setLabelFor(textField); ! assertFalse(textField.impl_isShowMnemonics()); ! assertFalse(label.impl_isShowMnemonics()); ! textField.impl_setShowMnemonics(true); ! assertTrue(textField.impl_isShowMnemonics()); ! assertTrue(label.impl_isShowMnemonics()); } @Test public void showMnemonicsOfLabelIsUpdatedWhenLabelForIsSet() { TextField textField = new TextField(); ! textField.impl_setShowMnemonics(true); label.setLabelFor(textField); ! assertTrue(textField.impl_isShowMnemonics()); ! assertTrue(label.impl_isShowMnemonics()); } @Test public void showMnemonicsOfLabelIsSetToFalseWhenLabelForIsCleared() { TextField textField = new TextField(); ! textField.impl_setShowMnemonics(true); label.setLabelFor(textField); label.setLabelFor(null); ! assertTrue(textField.impl_isShowMnemonics()); ! assertFalse(label.impl_isShowMnemonics()); } } --- 170,273 ---- // TODO on the showMnemonics of its labelFor, but since we do, I need // TODO to test it to make sure things get hooked up and unhooked @Test public void showMnemonicsHasNoListenersOnTextFieldByDefault() { // This is a sanity check test, so the following tests make sense TextField textField = new TextField(); ! assertEquals(0, getListenerCount(NodeHelper.showMnemonicsProperty(textField))); } @Test public void settingLabelForShouldAddListenerToShowMnemonics() { TextField textField = new TextField(); label.setLabelFor(textField); ! assertEquals(1, getListenerCount(NodeHelper.showMnemonicsProperty(textField))); } @Test public void settingLabelForShouldAddListenerToShowMnemonics_SetThroughProperty() { TextField textField = new TextField(); label.labelForProperty().set(textField); ! assertEquals(1, getListenerCount(NodeHelper.showMnemonicsProperty(textField))); } @Test public void settingLabelForShouldAddListenerToShowMnemonics_WhenBound() { TextField textField = new TextField(); ObjectProperty<TextField> other = new SimpleObjectProperty<TextField>(textField); label.labelForProperty().bind(other); ! assertEquals(1, getListenerCount(NodeHelper.showMnemonicsProperty(textField))); } @Test public void clearingLabelForShouldRemoveListenerFromShowMnemonics() { TextField textField = new TextField(); label.setLabelFor(textField); label.setLabelFor(null); ! assertEquals(0, getListenerCount(NodeHelper.showMnemonicsProperty(textField))); } @Test public void clearingLabelForShouldRemoveListenerFromShowMnemonics_SetThroughProperty() { TextField textField = new TextField(); label.labelForProperty().set(textField); label.labelForProperty().set(null); ! assertEquals(0, getListenerCount(NodeHelper.showMnemonicsProperty(textField))); } @Test public void clearingLabelForShouldRemoveListenerFromShowMnemonics_WhenBound() { TextField textField = new TextField(); ObjectProperty<TextField> other = new SimpleObjectProperty<TextField>(textField); label.labelForProperty().bind(other); other.set(null); ! assertEquals(0, getListenerCount(NodeHelper.showMnemonicsProperty(textField))); } @Test public void swappingLabelForShouldAddAndRemoveListenerFromShowMnemonics() { TextField a = new TextField(); TextField b = new TextField(); label.setLabelFor(a); label.setLabelFor(b); ! assertEquals(0, getListenerCount(NodeHelper.showMnemonicsProperty(a))); ! assertEquals(1, getListenerCount(NodeHelper.showMnemonicsProperty(b))); } @Test public void swappingLabelForShouldAddAndRemoveListenerFromShowMnemonics_SetThroughProperty() { TextField a = new TextField(); TextField b = new TextField(); label.labelForProperty().set(a); label.labelForProperty().set(b); ! assertEquals(0, getListenerCount(NodeHelper.showMnemonicsProperty(a))); ! assertEquals(1, getListenerCount(NodeHelper.showMnemonicsProperty(b))); } @Test public void swappingLabelForShouldAddAndRemoveListenerFromShowMnemonics_WhenBound() { TextField a = new TextField(); TextField b = new TextField(); ObjectProperty<TextField> other = new SimpleObjectProperty<TextField>(a); label.labelForProperty().bind(other); other.set(b); ! assertEquals(0, getListenerCount(NodeHelper.showMnemonicsProperty(a))); ! assertEquals(1, getListenerCount(NodeHelper.showMnemonicsProperty(b))); } @Test public void changingShowMnemonicsOnLabelForUpdatesStateForLabel() { TextField textField = new TextField(); label.setLabelFor(textField); ! assertFalse(NodeHelper.isShowMnemonics(textField)); ! assertFalse(NodeHelper.isShowMnemonics(label)); ! NodeHelper.setShowMnemonics(textField, true); ! assertTrue(NodeHelper.isShowMnemonics(textField)); ! assertTrue(NodeHelper.isShowMnemonics(label)); } @Test public void showMnemonicsOfLabelIsUpdatedWhenLabelForIsSet() { TextField textField = new TextField(); ! NodeHelper.setShowMnemonics(textField, true); label.setLabelFor(textField); ! assertTrue(NodeHelper.isShowMnemonics(textField)); ! assertTrue(NodeHelper.isShowMnemonics(label)); } @Test public void showMnemonicsOfLabelIsSetToFalseWhenLabelForIsCleared() { TextField textField = new TextField(); ! NodeHelper.setShowMnemonics(textField, true); label.setLabelFor(textField); label.setLabelFor(null); ! assertTrue(NodeHelper.isShowMnemonics(textField)); ! assertFalse(NodeHelper.isShowMnemonics(label)); } }
< prev index next >