use of com.canoo.dp.impl.remoting.MockedProperty in project dolphin-platform by canoo.
the class FXBinderTest method testJavaFXIntegerBidirectional.
@Test
public void testJavaFXIntegerBidirectional() {
Property<Integer> integerDolphinProperty = new MockedProperty<>();
Property<Number> numberDolphinProperty = new MockedProperty<>();
IntegerProperty integerJavaFXProperty = new SimpleIntegerProperty();
integerDolphinProperty.set(47);
assertNotEquals(integerJavaFXProperty.get(), 47);
Binding binding = FXBinder.bind(integerJavaFXProperty).bidirectionalToNumeric(integerDolphinProperty);
assertEquals(integerJavaFXProperty.get(), 47);
integerDolphinProperty.set(100);
assertEquals(integerJavaFXProperty.get(), 100);
integerDolphinProperty.set(null);
assertEquals(integerJavaFXProperty.get(), 0);
integerJavaFXProperty.set(12);
assertEquals(integerDolphinProperty.get().intValue(), 12);
integerJavaFXProperty.setValue(null);
assertEquals(integerDolphinProperty.get().intValue(), 0);
binding.unbind();
integerDolphinProperty.set(100);
assertEquals(integerJavaFXProperty.get(), 0);
numberDolphinProperty.set(12);
binding = FXBinder.bind(integerJavaFXProperty).bidirectionalTo(numberDolphinProperty);
assertEquals(integerJavaFXProperty.get(), 12);
numberDolphinProperty.set(null);
assertEquals(integerJavaFXProperty.get(), 0);
integerJavaFXProperty.set(12);
assertEquals(numberDolphinProperty.get().intValue(), 12);
integerJavaFXProperty.setValue(null);
assertEquals(numberDolphinProperty.get().intValue(), 0);
binding.unbind();
numberDolphinProperty.set(100);
assertEquals(integerJavaFXProperty.get(), 0);
}
use of com.canoo.dp.impl.remoting.MockedProperty in project dolphin-platform by canoo.
the class FXBinderTest method testJavaFXBooleanUnidirectionalWithConverter.
@Test
public void testJavaFXBooleanUnidirectionalWithConverter() {
Property<String> stringDolphinProperty = new MockedProperty<>();
BooleanProperty booleanJavaFXProperty = new SimpleBooleanProperty();
WritableBooleanValue writableBooleanValue = new SimpleBooleanProperty();
Converter<String, Boolean> stringBooleanConverter = s -> s == null ? null : Boolean.parseBoolean(s);
stringDolphinProperty.set("Hello");
assertEquals(booleanJavaFXProperty.get(), false);
Binding binding = FXBinder.bind(booleanJavaFXProperty).to(stringDolphinProperty, stringBooleanConverter);
assertEquals(booleanJavaFXProperty.get(), false);
stringDolphinProperty.set("true");
assertEquals(booleanJavaFXProperty.get(), true);
stringDolphinProperty.set(null);
assertEquals(booleanJavaFXProperty.get(), false);
binding.unbind();
stringDolphinProperty.set("true");
assertEquals(booleanJavaFXProperty.get(), false);
stringDolphinProperty.set("false");
binding = FXBinder.bind(writableBooleanValue).to(stringDolphinProperty, stringBooleanConverter);
assertEquals(writableBooleanValue.get(), false);
stringDolphinProperty.set("true");
assertEquals(writableBooleanValue.get(), true);
stringDolphinProperty.set(null);
assertEquals(writableBooleanValue.get(), false);
binding.unbind();
stringDolphinProperty.set("true");
assertEquals(writableBooleanValue.get(), false);
}
use of com.canoo.dp.impl.remoting.MockedProperty in project dolphin-platform by canoo.
the class FXBinderTest method testJavaFXStringUnidirectional.
@Test
public void testJavaFXStringUnidirectional() {
Property<String> stringDolphinProperty = new MockedProperty<>();
StringProperty stringJavaFXProperty = new SimpleStringProperty();
WritableStringValue writableStringValue = new SimpleStringProperty();
stringDolphinProperty.set("Hello");
assertNotEquals(stringJavaFXProperty.get(), "Hello");
Binding binding = FXBinder.bind(stringJavaFXProperty).to(stringDolphinProperty);
assertEquals(stringJavaFXProperty.get(), "Hello");
stringDolphinProperty.set("Hello JavaFX");
assertEquals(stringJavaFXProperty.get(), "Hello JavaFX");
stringDolphinProperty.set(null);
assertEquals(stringJavaFXProperty.get(), null);
binding.unbind();
stringDolphinProperty.set("Hello JavaFX");
assertEquals(stringJavaFXProperty.get(), null);
binding = FXBinder.bind(writableStringValue).to(stringDolphinProperty);
assertEquals(writableStringValue.get(), "Hello JavaFX");
stringDolphinProperty.set("Dolphin Platform");
assertEquals(writableStringValue.get(), "Dolphin Platform");
stringDolphinProperty.set(null);
assertEquals(writableStringValue.get(), null);
binding.unbind();
stringDolphinProperty.set("Dolphin Platform");
assertEquals(writableStringValue.get(), null);
}
use of com.canoo.dp.impl.remoting.MockedProperty in project dolphin-platform by canoo.
the class FXBinderTest method testJavaFXIntegerUnidirectional.
@Test
public void testJavaFXIntegerUnidirectional() {
Property<Integer> integerDolphinProperty = new MockedProperty<>();
Property<Number> numberDolphinProperty = new MockedProperty<>();
IntegerProperty integerJavaFXProperty = new SimpleIntegerProperty();
WritableIntegerValue writableIntegerValue = new SimpleIntegerProperty();
integerDolphinProperty.set(47);
assertNotEquals(integerJavaFXProperty.doubleValue(), 47);
Binding binding = FXBinder.bind(integerJavaFXProperty).to(integerDolphinProperty);
assertEquals(integerJavaFXProperty.get(), 47);
integerDolphinProperty.set(100);
assertEquals(integerJavaFXProperty.get(), 100);
integerDolphinProperty.set(null);
assertEquals(integerJavaFXProperty.get(), 0);
binding.unbind();
integerDolphinProperty.set(100);
assertEquals(integerJavaFXProperty.get(), 0);
numberDolphinProperty.set(12);
binding = FXBinder.bind(integerJavaFXProperty).to(numberDolphinProperty);
assertEquals(integerJavaFXProperty.get(), 12);
numberDolphinProperty.set(null);
assertEquals(integerJavaFXProperty.get(), 0);
binding.unbind();
numberDolphinProperty.set(100);
assertEquals(integerJavaFXProperty.get(), 0);
integerDolphinProperty.set(47);
binding = FXBinder.bind(writableIntegerValue).to(integerDolphinProperty);
assertEquals(writableIntegerValue.get(), 47);
integerDolphinProperty.set(100);
assertEquals(writableIntegerValue.get(), 100);
integerDolphinProperty.set(null);
assertEquals(writableIntegerValue.get(), 0);
binding.unbind();
integerDolphinProperty.set(100);
assertEquals(writableIntegerValue.get(), 0);
}
use of com.canoo.dp.impl.remoting.MockedProperty in project dolphin-platform by canoo.
the class FXBinderTest method testJavaFXDoubleBidirectionalWithConverter.
@Test
public void testJavaFXDoubleBidirectionalWithConverter() {
Property<String> stringDolphinProperty = new MockedProperty<>();
DoubleProperty doubleJavaFXProperty = new SimpleDoubleProperty();
Converter<String, Double> stringDoubleConverter = s -> s == null ? null : Double.parseDouble(s);
Converter<Double, String> doubleStringConverter = d -> d == null ? null : d.toString();
BidirectionalConverter<String, Double> doubleBidirectionalConverter = new DefaultBidirectionalConverter<>(stringDoubleConverter, doubleStringConverter);
stringDolphinProperty.set("47.0");
assertNotEquals(doubleJavaFXProperty.doubleValue(), 47.0, EPSILON);
Binding binding = FXBinder.bind(doubleJavaFXProperty).bidirectionalToNumeric(stringDolphinProperty, doubleBidirectionalConverter);
assertEquals(doubleJavaFXProperty.doubleValue(), 47.0, EPSILON);
stringDolphinProperty.set("100.0");
assertEquals(doubleJavaFXProperty.doubleValue(), 100.0, EPSILON);
stringDolphinProperty.set(null);
assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
doubleJavaFXProperty.set(12.0);
assertEquals(stringDolphinProperty.get(), "12.0");
doubleJavaFXProperty.setValue(null);
assertEquals(stringDolphinProperty.get(), "0.0");
binding.unbind();
stringDolphinProperty.set("100.0");
assertEquals(doubleJavaFXProperty.doubleValue(), 0.0, EPSILON);
}
Aggregations