Search in sources :

Example 26 with BoolValueProperty

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

Example 27 with BoolValueProperty

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

Example 28 with BoolValueProperty

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

the class DoubleExpressionsTest method testGreaterThanExpression.

@Test
public void testGreaterThanExpression() {
    BoolValueProperty result = new BoolValueProperty();
    DoubleValueProperty lhs = new DoubleValueProperty();
    DoubleValueProperty rhs = new DoubleValueProperty();
    BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
    bindings.bind(result, lhs.isGreaterThan(rhs));
    assertThat(result.get()).isFalse();
    lhs.set(10.0);
    assertThat(result.get()).isTrue();
    rhs.set(10.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 29 with BoolValueProperty

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

the class ServiceContextTest method dataModelCanRegisterActionsAndObservableValues.

@Test
public void dataModelCanRegisterActionsAndObservableValues() throws Exception {
    ServiceContext context = new ServiceContext("Gradle");
    {
        final IntValueProperty count = new IntValueProperty();
        Runnable incCount = new Runnable() {

            @Override
            public void run() {
                count.increment();
            }
        };
        final StringValueProperty title = new StringValueProperty("Title");
        final BoolValueProperty enabled = new BoolValueProperty(true);
        Runnable toggleEnabled = new Runnable() {

            @Override
            public void run() {
                enabled.invert();
            }
        };
        context.putValue("count", count);
        context.putValue("title", title);
        context.putValue("enabled", enabled);
        context.putAction("incCount", incCount);
        context.putAction("toggleEnabled", toggleEnabled);
    }
    IntValueProperty count = (IntValueProperty) context.getValue("count");
    StringValueProperty title = (StringValueProperty) context.getValue("title");
    BoolValueProperty enabled = (BoolValueProperty) context.getValue("enabled");
    assertThat(title.get()).isEqualTo("Title");
    assertThat(count.get()).isEqualTo(0);
    context.getAction("incCount").run();
    assertThat(count.get()).isEqualTo(1);
    assertThat(enabled.get()).isTrue();
    context.getAction("toggleEnabled").run();
    assertThat(enabled.get()).isFalse();
}
Also used : IntValueProperty(com.android.tools.idea.ui.properties.core.IntValueProperty) 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