use of com.android.tools.idea.ui.properties.core.IntValueProperty in project android by JetBrains.
the class IntExpressionsTest method testSumExpression.
@Test
public void testSumExpression() {
IntValueProperty sum = new IntValueProperty();
IntValueProperty a = new IntValueProperty(1);
IntValueProperty b = new IntValueProperty(2);
IntValueProperty c = new IntValueProperty(3);
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(sum, new SumExpression(a, b, c));
assertThat(sum.get()).isEqualTo(6);
a.set(10);
b.set(100);
c.set(1000);
assertThat(sum.get()).isEqualTo(1110);
c.set(1001);
assertThat(sum.get()).isEqualTo(1111);
}
use of com.android.tools.idea.ui.properties.core.IntValueProperty in project android by JetBrains.
the class OptionalExpressionsTest method testAsOptionalExpression.
@Test
public void testAsOptionalExpression() {
IntProperty intProperty = new IntValueProperty(42);
AsOptionalExpression<Integer> asOptionalExpr = new AsOptionalExpression<>(intProperty);
assertThat(asOptionalExpr.get().get()).isEqualTo(42);
intProperty.set(123);
assertThat(asOptionalExpr.get().get()).isEqualTo(123);
}
use of com.android.tools.idea.ui.properties.core.IntValueProperty in project android by JetBrains.
the class StringExpressionsTest method testFormatStringExpression.
@Test
public void testFormatStringExpression() throws Exception {
IntValueProperty arg1 = new IntValueProperty(42);
BoolValueProperty arg2 = new BoolValueProperty(true);
StringValueProperty destValue = new StringValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(destValue, new FormatExpression("The answer is %1$s. Hitchhiker reference? %2$s", arg1, arg2));
assertThat(destValue.get()).isEqualTo("The answer is 42. Hitchhiker reference? true");
arg1.set(2);
arg2.set(false);
assertThat(destValue.get()).isEqualTo("The answer is 2. Hitchhiker reference? false");
}
use of com.android.tools.idea.ui.properties.core.IntValueProperty in project android by JetBrains.
the class IntExpressionsTest method testLessThanValueExpression.
@Test
public void testLessThanValueExpression() {
BoolValueProperty result = new BoolValueProperty();
IntValueProperty lhs = new IntValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(result, lhs.isLessThan(10));
assertThat(result.get()).isTrue();
lhs.set(10);
assertThat(result.get()).isFalse();
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 testGreaterThanValueExpression.
@Test
public void testGreaterThanValueExpression() {
BoolValueProperty result = new BoolValueProperty();
IntValueProperty lhs = new IntValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(result, lhs.isGreaterThan(10));
assertThat(result.get()).isFalse();
lhs.set(10);
assertThat(result.get()).isFalse();
lhs.set(20);
assertThat(result.get()).isTrue();
}
Aggregations