Search in sources :

Example 11 with StringValueProperty

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

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

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

StringValueProperty (com.android.tools.idea.ui.properties.core.StringValueProperty)13 Test (org.junit.Test)12 BindingsManager (com.android.tools.idea.ui.properties.BindingsManager)4 BoolValueProperty (com.android.tools.idea.ui.properties.core.BoolValueProperty)4 IntValueProperty (com.android.tools.idea.ui.properties.core.IntValueProperty)3 StringProperty (com.android.tools.idea.ui.properties.core.StringProperty)2 AndroidVersion (com.android.sdklib.AndroidVersion)1 DomainToPackageExpression (com.android.tools.idea.npw.project.DomainToPackageExpression)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