use of com.android.tools.idea.ui.properties.BindingsManager 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.BindingsManager 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();
}
use of com.android.tools.idea.ui.properties.BindingsManager in project android by JetBrains.
the class IntExpressionsTest method testGreaterThanEqualExpression.
@Test
public void testGreaterThanEqualExpression() {
BoolValueProperty result = new BoolValueProperty();
IntValueProperty lhs = new IntValueProperty();
IntValueProperty rhs = new IntValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(result, lhs.isGreaterThanEqualTo(rhs));
assertThat(result.get()).isTrue();
rhs.set(10);
assertThat(result.get()).isFalse();
lhs.set(10);
assertThat(result.get()).isTrue();
rhs.set(20);
assertThat(result.get()).isFalse();
}
use of com.android.tools.idea.ui.properties.BindingsManager in project android by JetBrains.
the class DoubleExpressionsTest method testGreaterThanEqualExpression.
@Test
public void testGreaterThanEqualExpression() {
BoolValueProperty result = new BoolValueProperty();
DoubleValueProperty lhs = new DoubleValueProperty();
DoubleValueProperty rhs = new DoubleValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(result, lhs.isGreaterThanEqualTo(rhs));
assertThat(result.get()).isTrue();
rhs.set(10.0);
assertThat(result.get()).isFalse();
lhs.set(10.0);
assertThat(result.get()).isTrue();
rhs.set(20.0);
assertThat(result.get()).isFalse();
}
use of com.android.tools.idea.ui.properties.BindingsManager in project android by JetBrains.
the class AdapterPropertiesTest method bindingStringToDoubleWithBadParameters.
@Test
public void bindingStringToDoubleWithBadParameters() throws Exception {
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
StringProperty doubleString = new StringValueProperty("0");
DoubleProperty doubleValue = new DoubleValueProperty(0.9876);
//noinspection EmptyCatchBlock
try {
bindings.bindTwoWay(new StringToDoubleAdapterProperty(doubleString, 4, 3), doubleValue);
fail("Expect an exception because maxDecimals is specified smaller than num decimals");
} catch (IllegalArgumentException unused) {
}
}
Aggregations