use of com.android.tools.idea.ui.properties.BindingsManager in project android by JetBrains.
the class StringExpressionsTest method testTrimExpression.
@Test
public void testTrimExpression() throws Exception {
StringValueProperty srcValue = new StringValueProperty();
StringValueProperty destValue = new StringValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(destValue, srcValue.trim());
assertThat(destValue.get()).isEmpty();
srcValue.set(" Preceded by whitespace");
assertThat(destValue.get()).isEqualTo("Preceded by whitespace");
srcValue.set(" Surrounded by whitespace ");
assertThat(destValue.get()).isEqualTo("Surrounded by whitespace");
srcValue.set(" ");
assertThat(destValue.get()).isEmpty();
srcValue.set(" \t \n ");
assertThat(destValue.get()).isEmpty();
}
use of com.android.tools.idea.ui.properties.BindingsManager in project android by JetBrains.
the class BooleanExpressionsTest method testIsEmptyStringExpression.
@Test
public void testIsEmptyStringExpression() throws Exception {
StringValueProperty srcValue = new StringValueProperty();
BoolValueProperty destValue = new BoolValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(destValue, srcValue.isEmpty());
assertThat(destValue.get()).isTrue();
srcValue.set("Not Empty");
assertThat(destValue.get()).isFalse();
srcValue.set(" ");
assertThat(destValue.get()).isFalse();
srcValue.set("");
assertThat(destValue.get()).isTrue();
}
use of com.android.tools.idea.ui.properties.BindingsManager in project android by JetBrains.
the class BooleanExpressionsTest method testIsEqualToExpression.
@Test
public void testIsEqualToExpression() throws Exception {
StringValueProperty srcValue = new StringValueProperty("Initial Value");
BoolValueProperty destValue = new BoolValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(destValue, srcValue.isEqualTo("Modified Value"));
assertThat(destValue.get()).isFalse();
srcValue.set("Modified Value");
assertThat(destValue.get()).isTrue();
srcValue.set("Final Value");
assertThat(destValue.get()).isFalse();
}
use of com.android.tools.idea.ui.properties.BindingsManager in project android by JetBrains.
the class BooleanExpressionsTest method testNotExpression.
@Test
public void testNotExpression() throws Exception {
BoolValueProperty srcValue = new BoolValueProperty(true);
BoolValueProperty destValue = new BoolValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(destValue, BooleanExpressions.not(srcValue));
assertThat(srcValue.get()).isTrue();
assertThat(destValue.get()).isFalse();
srcValue.set(false);
assertThat(srcValue.get()).isFalse();
assertThat(destValue.get()).isTrue();
}
use of com.android.tools.idea.ui.properties.BindingsManager in project android by JetBrains.
the class DoubleExpressionsTest method testGreaterThanValueExpression.
@Test
public void testGreaterThanValueExpression() {
BoolValueProperty result = new BoolValueProperty();
DoubleValueProperty lhs = new DoubleValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(result, lhs.isGreaterThan(10.0));
assertThat(result.get()).isFalse();
lhs.set(10.0);
assertThat(result.get()).isFalse();
lhs.set(20.0);
assertThat(result.get()).isTrue();
}
Aggregations