use of com.android.tools.idea.ui.properties.BindingsManager in project android by JetBrains.
the class AdapterPropertiesTest method bindingOptionalToValueAdapterWithDefaultValueWorks.
@Test
public void bindingOptionalToValueAdapterWithDefaultValueWorks() throws Exception {
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
OptionalProperty<String> optionalValue = new OptionalValueProperty<>();
StringProperty stringValue = new StringValueProperty();
bindings.bindTwoWay(stringValue, new OptionalToValuePropertyAdapter<>(optionalValue, "Initial"));
assertThat(stringValue.get()).isEqualTo("Initial");
stringValue.set("Modified");
assertThat(optionalValue.getValue()).isEqualTo("Modified");
optionalValue.clear();
assertThat(stringValue.get()).isEqualTo("Modified");
}
use of com.android.tools.idea.ui.properties.BindingsManager in project android by JetBrains.
the class AdapterPropertiesTest method bindingOptionalToValueAdapterWorks.
@Test
public void bindingOptionalToValueAdapterWorks() throws Exception {
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
OptionalProperty<String> optionalValue = new OptionalValueProperty<>("Initial");
StringProperty stringValue = new StringValueProperty();
OptionalToValuePropertyAdapter<String> adapterProperty = new OptionalToValuePropertyAdapter<>(optionalValue);
bindings.bindTwoWay(stringValue, adapterProperty);
assertThat(stringValue.get()).isEqualTo("Initial");
assertThat(adapterProperty.inSync().get()).isTrue();
stringValue.set("Modified");
assertThat(optionalValue.getValue()).isEqualTo("Modified");
assertThat(adapterProperty.inSync().get()).isTrue();
optionalValue.clear();
assertThat(stringValue.get()).isEqualTo("Modified");
assertThat(adapterProperty.inSync().get()).isFalse();
}
use of com.android.tools.idea.ui.properties.BindingsManager in project android by JetBrains.
the class BooleanExpressionsTest method testOrExpression.
@Test
public void testOrExpression() throws Exception {
BoolValueProperty srcValue1 = new BoolValueProperty();
BoolValueProperty srcValue2 = new BoolValueProperty();
BoolValueProperty destValue = new BoolValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(destValue, srcValue1.or(srcValue2));
assertThat(srcValue1.get()).isFalse();
assertThat(srcValue2.get()).isFalse();
assertThat(destValue.get()).isFalse();
srcValue1.set(true);
srcValue2.set(false);
assertThat(srcValue1.get()).isTrue();
assertThat(srcValue2.get()).isFalse();
assertThat(destValue.get()).isTrue();
srcValue1.set(false);
srcValue2.set(true);
assertThat(srcValue1.get()).isFalse();
assertThat(srcValue2.get()).isTrue();
assertThat(destValue.get()).isTrue();
srcValue1.set(true);
srcValue2.set(true);
assertThat(srcValue1.get()).isTrue();
assertThat(srcValue2.get()).isTrue();
assertThat(destValue.get()).isTrue();
}
use of com.android.tools.idea.ui.properties.BindingsManager in project android by JetBrains.
the class BooleanExpressionsTest method testAndExpression.
@Test
public void testAndExpression() throws Exception {
BoolValueProperty srcValue1 = new BoolValueProperty();
BoolValueProperty srcValue2 = new BoolValueProperty();
BoolValueProperty destValue = new BoolValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(destValue, srcValue1.and(srcValue2));
assertThat(srcValue1.get()).isFalse();
assertThat(srcValue2.get()).isFalse();
assertThat(destValue.get()).isFalse();
srcValue1.set(true);
srcValue2.set(false);
assertThat(srcValue1.get()).isTrue();
assertThat(srcValue2.get()).isFalse();
assertThat(destValue.get()).isFalse();
srcValue1.set(false);
srcValue2.set(true);
assertThat(srcValue1.get()).isFalse();
assertThat(srcValue2.get()).isTrue();
assertThat(destValue.get()).isFalse();
srcValue1.set(true);
srcValue2.set(true);
assertThat(srcValue1.get()).isTrue();
assertThat(srcValue2.get()).isTrue();
assertThat(destValue.get()).isTrue();
}
use of com.android.tools.idea.ui.properties.BindingsManager in project android by JetBrains.
the class BooleanExpressionsTest method testAnyExpression.
@Test
public void testAnyExpression() throws Exception {
BoolValueProperty srcValue1 = new BoolValueProperty();
BoolValueProperty srcValue2 = new BoolValueProperty();
BoolValueProperty srcValue3 = new BoolValueProperty();
BoolValueProperty destValue = new BoolValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(destValue, BooleanExpressions.any(srcValue1, srcValue2, srcValue3));
assertThat(srcValue1.get()).isFalse();
assertThat(srcValue2.get()).isFalse();
assertThat(srcValue3.get()).isFalse();
assertThat(destValue.get()).isFalse();
srcValue1.set(true);
srcValue2.set(false);
srcValue3.set(false);
assertThat(srcValue1.get()).isTrue();
assertThat(srcValue2.get()).isFalse();
assertThat(srcValue3.get()).isFalse();
assertThat(destValue.get()).isTrue();
srcValue1.set(false);
srcValue2.set(true);
srcValue3.set(false);
assertThat(srcValue1.get()).isFalse();
assertThat(srcValue2.get()).isTrue();
assertThat(srcValue3.get()).isFalse();
assertThat(destValue.get()).isTrue();
srcValue1.set(true);
srcValue2.set(false);
srcValue3.set(true);
assertThat(srcValue1.get()).isTrue();
assertThat(srcValue2.get()).isFalse();
assertThat(srcValue3.get()).isTrue();
assertThat(destValue.get()).isTrue();
srcValue1.set(true);
srcValue2.set(true);
srcValue3.set(true);
assertThat(srcValue1.get()).isTrue();
assertThat(srcValue2.get()).isTrue();
assertThat(srcValue3.get()).isTrue();
assertThat(destValue.get()).isTrue();
srcValue1.set(false);
srcValue2.set(false);
srcValue3.set(false);
assertThat(srcValue1.get()).isFalse();
assertThat(srcValue2.get()).isFalse();
assertThat(srcValue3.get()).isFalse();
assertThat(destValue.get()).isFalse();
}
Aggregations