Search in sources :

Example 16 with BoolValueProperty

use of com.android.tools.idea.ui.properties.core.BoolValueProperty in project android by JetBrains.

the class IntExpressionsTest method testLessThanExpression.

@Test
public void testLessThanExpression() {
    BoolValueProperty result = new BoolValueProperty();
    IntValueProperty lhs = new IntValueProperty();
    IntValueProperty rhs = new IntValueProperty();
    BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
    bindings.bind(result, lhs.isLessThan(rhs));
    assertThat(result.get()).isFalse();
    rhs.set(10);
    assertThat(result.get()).isTrue();
    lhs.set(10);
    assertThat(result.get()).isFalse();
}
Also used : IntValueProperty(com.android.tools.idea.ui.properties.core.IntValueProperty) BindingsManager(com.android.tools.idea.ui.properties.BindingsManager) BoolValueProperty(com.android.tools.idea.ui.properties.core.BoolValueProperty) Test(org.junit.Test)

Example 17 with BoolValueProperty

use of com.android.tools.idea.ui.properties.core.BoolValueProperty in project android by JetBrains.

the class IntExpressionsTest method testGreaterThanExpression.

@Test
public void testGreaterThanExpression() {
    BoolValueProperty result = new BoolValueProperty();
    IntValueProperty lhs = new IntValueProperty();
    IntValueProperty rhs = new IntValueProperty();
    BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
    bindings.bind(result, lhs.isGreaterThan(rhs));
    assertThat(result.get()).isFalse();
    lhs.set(10);
    assertThat(result.get()).isTrue();
    rhs.set(10);
    assertThat(result.get()).isFalse();
}
Also used : IntValueProperty(com.android.tools.idea.ui.properties.core.IntValueProperty) BindingsManager(com.android.tools.idea.ui.properties.BindingsManager) BoolValueProperty(com.android.tools.idea.ui.properties.core.BoolValueProperty) Test(org.junit.Test)

Example 18 with BoolValueProperty

use of com.android.tools.idea.ui.properties.core.BoolValueProperty 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");
}
Also used : IntValueProperty(com.android.tools.idea.ui.properties.core.IntValueProperty) 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 19 with BoolValueProperty

use of com.android.tools.idea.ui.properties.core.BoolValueProperty 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 20 with BoolValueProperty

use of com.android.tools.idea.ui.properties.core.BoolValueProperty 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)

Aggregations

BoolValueProperty (com.android.tools.idea.ui.properties.core.BoolValueProperty)29 Test (org.junit.Test)29 BindingsManager (com.android.tools.idea.ui.properties.BindingsManager)27 IntValueProperty (com.android.tools.idea.ui.properties.core.IntValueProperty)13 DoubleValueProperty (com.android.tools.idea.ui.properties.core.DoubleValueProperty)10 StringValueProperty (com.android.tools.idea.ui.properties.core.StringValueProperty)4