use of com.android.tools.idea.ui.properties.core.BoolValueProperty in project android by JetBrains.
the class BindingsManagerTest method oneWayBindingsCanBeEnabledConditionally.
@Test
public void oneWayBindingsCanBeEnabledConditionally() {
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
IntValueProperty srcProperty = new IntValueProperty(10);
IntValueProperty destProperty = new IntValueProperty(-5);
BoolValueProperty bindingEnabled = new BoolValueProperty(true);
bindings.bind(destProperty, srcProperty, bindingEnabled);
assertThat(destProperty.get()).isEqualTo(10);
srcProperty.set(20);
assertThat(destProperty.get()).isEqualTo(20);
bindingEnabled.set(false);
assertThat(destProperty.get()).isEqualTo(20);
srcProperty.set(30);
assertThat(destProperty.get()).isEqualTo(20);
srcProperty.set(40);
assertThat(destProperty.get()).isEqualTo(20);
bindingEnabled.set(true);
assertThat(destProperty.get()).isEqualTo(40);
srcProperty.set(50);
assertThat(destProperty.get()).isEqualTo(50);
}
use of com.android.tools.idea.ui.properties.core.BoolValueProperty 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.core.BoolValueProperty 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.core.BoolValueProperty 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();
}
use of com.android.tools.idea.ui.properties.core.BoolValueProperty in project android by JetBrains.
the class DoubleExpressionsTest method testGreaterThanEqualValueExpression.
@Test
public void testGreaterThanEqualValueExpression() {
BoolValueProperty result = new BoolValueProperty();
DoubleValueProperty lhs = new DoubleValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(result, lhs.isGreaterThanEqualTo(10.0));
assertThat(result.get()).isFalse();
lhs.set(10.0);
assertThat(result.get()).isTrue();
lhs.set(20.0);
assertThat(result.get()).isTrue();
}
Aggregations