Search in sources :

Example 6 with DoubleValueProperty

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

Example 7 with DoubleValueProperty

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

the class DoubleExpressionsTest method testLessThanValueExpression.

@Test
public void testLessThanValueExpression() {
    BoolValueProperty result = new BoolValueProperty();
    DoubleValueProperty lhs = new DoubleValueProperty();
    BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
    bindings.bind(result, lhs.isLessThan(10.0));
    assertThat(result.get()).isTrue();
    lhs.set(10.0);
    assertThat(result.get()).isFalse();
    lhs.set(20.0);
    assertThat(result.get()).isFalse();
}
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)

Example 8 with DoubleValueProperty

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

the class DoubleExpressionsTest method testIsEqualWithValueExpression.

@Test
public void testIsEqualWithValueExpression() {
    BoolValueProperty result = new BoolValueProperty();
    DoubleValueProperty lhs = new DoubleValueProperty();
    BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
    bindings.bind(result, lhs.isEqualTo(10));
    assertThat(result.get()).isFalse();
    lhs.set(10.0);
    assertThat(result.get()).isTrue();
    lhs.set(20.0);
    assertThat(result.get()).isFalse();
}
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)

Example 9 with DoubleValueProperty

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

the class DoubleExpressionsTest method testSumExpression.

@Test
public void testSumExpression() {
    DoubleValueProperty sum = new DoubleValueProperty();
    DoubleValueProperty a = new DoubleValueProperty(1.0);
    DoubleValueProperty b = new DoubleValueProperty(2.0);
    DoubleValueProperty c = new DoubleValueProperty(3.0);
    BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
    bindings.bind(sum, new com.android.tools.idea.ui.properties.expressions.double_.SumExpression(a, b, c));
    assertThat(sum.get()).isWithin(0.01).of(6.0);
    a.set(10.0);
    b.set(100.0);
    c.set(1000.0);
    assertThat(sum.get()).isWithin(0.01).of(1110.0);
    c.set(1001.0);
    assertThat(sum.get()).isWithin(0.01).of(1111.0);
}
Also used : DoubleValueProperty(com.android.tools.idea.ui.properties.core.DoubleValueProperty) BindingsManager(com.android.tools.idea.ui.properties.BindingsManager) Test(org.junit.Test)

Example 10 with DoubleValueProperty

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

the class DoubleExpressionsTest method testIsEqualExpression.

@Test
public void testIsEqualExpression() {
    BoolValueProperty result = new BoolValueProperty();
    DoubleValueProperty lhs = new DoubleValueProperty();
    DoubleValueProperty rhs = new DoubleValueProperty();
    BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
    bindings.bind(result, lhs.isEqualTo(rhs));
    assertThat(result.get()).isTrue();
    lhs.set(10.0);
    assertThat(result.get()).isFalse();
    rhs.set(10.0);
    assertThat(result.get()).isTrue();
    rhs.set(20.0);
    assertThat(result.get()).isFalse();
}
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)11 DoubleValueProperty (com.android.tools.idea.ui.properties.core.DoubleValueProperty)11 Test (org.junit.Test)11 BoolValueProperty (com.android.tools.idea.ui.properties.core.BoolValueProperty)10