use of com.android.tools.idea.ui.properties.core.IntValueProperty 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.IntValueProperty in project android by JetBrains.
the class ExpressionTest method testSimpleExpression.
@Test
public void testSimpleExpression() throws Exception {
final IntProperty intValue = new IntValueProperty(13);
final Expression<String> intToString = new Expression<String>(intValue) {
@NotNull
@Override
public String get() {
return intValue.get().toString();
}
};
assertThat(intToString.get()).isEqualTo("13");
intValue.set(-13);
assertThat(intToString.get()).isEqualTo("-13");
}
use of com.android.tools.idea.ui.properties.core.IntValueProperty in project android by JetBrains.
the class IntExpressionsTest method testIsEqualWithValueExpression.
@Test
public void testIsEqualWithValueExpression() {
BoolValueProperty result = new BoolValueProperty();
IntValueProperty lhs = new IntValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(result, lhs.isEqualTo(10));
assertThat(result.get()).isFalse();
lhs.set(10);
assertThat(result.get()).isTrue();
lhs.set(20);
assertThat(result.get()).isFalse();
}
use of com.android.tools.idea.ui.properties.core.IntValueProperty in project android by JetBrains.
the class IntExpressionsTest method testIsEqualExpression.
@Test
public void testIsEqualExpression() {
BoolValueProperty result = new BoolValueProperty();
IntValueProperty lhs = new IntValueProperty();
IntValueProperty rhs = new IntValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(result, lhs.isEqualTo(rhs));
assertThat(result.get()).isTrue();
lhs.set(10);
assertThat(result.get()).isFalse();
rhs.set(10);
assertThat(result.get()).isTrue();
rhs.set(20);
assertThat(result.get()).isFalse();
}
use of com.android.tools.idea.ui.properties.core.IntValueProperty in project android by JetBrains.
the class IntExpressionsTest method testGreaterThanEqualValueExpression.
@Test
public void testGreaterThanEqualValueExpression() {
BoolValueProperty result = new BoolValueProperty();
IntValueProperty lhs = new IntValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(result, lhs.isGreaterThanEqualTo(10));
assertThat(result.get()).isFalse();
lhs.set(10);
assertThat(result.get()).isTrue();
lhs.set(20);
assertThat(result.get()).isTrue();
}
Aggregations