Search in sources :

Example 21 with BindingsManager

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();
}
Also used : BindingsManager(com.android.tools.idea.ui.properties.BindingsManager) StringValueProperty(com.android.tools.idea.ui.properties.core.StringValueProperty) Test(org.junit.Test)

Example 22 with BindingsManager

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();
}
Also used : BindingsManager(com.android.tools.idea.ui.properties.BindingsManager) StringValueProperty(com.android.tools.idea.ui.properties.core.StringValueProperty) BoolValueProperty(com.android.tools.idea.ui.properties.core.BoolValueProperty) Test(org.junit.Test)

Example 23 with BindingsManager

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();
}
Also used : BindingsManager(com.android.tools.idea.ui.properties.BindingsManager) StringValueProperty(com.android.tools.idea.ui.properties.core.StringValueProperty) BoolValueProperty(com.android.tools.idea.ui.properties.core.BoolValueProperty) Test(org.junit.Test)

Example 24 with BindingsManager

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();
}
Also used : BindingsManager(com.android.tools.idea.ui.properties.BindingsManager) BoolValueProperty(com.android.tools.idea.ui.properties.core.BoolValueProperty) Test(org.junit.Test)

Example 25 with BindingsManager

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();
}
Also used : DoubleValueProperty(com.android.tools.idea.ui.properties.core.DoubleValueProperty) BindingsManager(com.android.tools.idea.ui.properties.BindingsManager) BoolValueProperty(com.android.tools.idea.ui.properties.core.BoolValueProperty) Test(org.junit.Test)

Aggregations

BindingsManager (com.android.tools.idea.ui.properties.BindingsManager)38 Test (org.junit.Test)38 BoolValueProperty (com.android.tools.idea.ui.properties.core.BoolValueProperty)27 IntValueProperty (com.android.tools.idea.ui.properties.core.IntValueProperty)12 DoubleValueProperty (com.android.tools.idea.ui.properties.core.DoubleValueProperty)11 StringValueProperty (com.android.tools.idea.ui.properties.core.StringValueProperty)4