Search in sources :

Example 16 with IntValueProperty

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

Example 17 with IntValueProperty

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

Example 18 with IntValueProperty

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");
}
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 IntValueProperty

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();
}
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 20 with IntValueProperty

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();
}
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)

Aggregations

IntValueProperty (com.android.tools.idea.ui.properties.core.IntValueProperty)23 Test (org.junit.Test)22 BoolValueProperty (com.android.tools.idea.ui.properties.core.BoolValueProperty)13 BindingsManager (com.android.tools.idea.ui.properties.BindingsManager)12 StringValueProperty (com.android.tools.idea.ui.properties.core.StringValueProperty)3 IntProperty (com.android.tools.idea.ui.properties.core.IntProperty)2 AndroidVersion (com.android.sdklib.AndroidVersion)1 TemplateMetadata.getBuildApiString (com.android.tools.idea.templates.TemplateMetadata.getBuildApiString)1 StringExpression (com.android.tools.idea.ui.properties.expressions.string.StringExpression)1 AndroidPlatform (org.jetbrains.android.sdk.AndroidPlatform)1 NotNull (org.jetbrains.annotations.NotNull)1