Search in sources :

Example 1 with StringValueProperty

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

the class BindingsManagerTest method releaseTwoWayWithOneArgDisconnectsAllMatchingBindings.

@Test
public void releaseTwoWayWithOneArgDisconnectsAllMatchingBindings() throws Exception {
    BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
    StringValueProperty property1 = new StringValueProperty("First");
    StringValueProperty property2 = new StringValueProperty("Second");
    StringValueProperty property3 = new StringValueProperty("Third");
    bindings.bindTwoWay(property1, property2);
    bindings.bindTwoWay(property3, property2);
    assertThat(property1.get()).isEqualTo("Second");
    assertThat(property3.get()).isEqualTo("Second");
    bindings.releaseTwoWay(property2);
    property1.set("Property1");
    assertThat(property2.get()).isEqualTo("Second");
    property3.set("Property3");
    assertThat(property2.get()).isEqualTo("Second");
}
Also used : StringValueProperty(com.android.tools.idea.ui.properties.core.StringValueProperty) Test(org.junit.Test)

Example 2 with StringValueProperty

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

the class ExpressionTest method expressionsNeedAtLeastOneObservable.

@Test(expected = IllegalArgumentException.class)
public void expressionsNeedAtLeastOneObservable() throws Exception {
    final StringProperty value = new StringValueProperty();
    Expression expr = new // This should be "new StringExpression(value)"
    StringExpression() {

        @NotNull
        @Override
        public String get() {
            return value.get();
        }
    };
}
Also used : StringExpression(com.android.tools.idea.ui.properties.expressions.string.StringExpression) StringExpression(com.android.tools.idea.ui.properties.expressions.string.StringExpression) StringProperty(com.android.tools.idea.ui.properties.core.StringProperty) StringValueProperty(com.android.tools.idea.ui.properties.core.StringValueProperty) Test(org.junit.Test)

Example 3 with StringValueProperty

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

the class DomainToPackageExpressionTest method packageNameDeriverSantizesCompanyDomainKey.

@Test
public void packageNameDeriverSantizesCompanyDomainKey() {
    StringProperty companyDomain = new StringValueProperty("sub.exa-mple.com");
    StringProperty applicationName = new StringValueProperty("My&App");
    Expression<String> computedPackageName = new DomainToPackageExpression(companyDomain, applicationName);
    assertEquals("com.exa_mple.sub.myapp", computedPackageName.get());
    companyDomain.set("#.badstartchar.com");
    assertEquals("com.badstartchar.myapp", computedPackageName.get());
    companyDomain.set("TEST.ALLCAPS.COM");
    assertEquals("com.allcaps.test.myapp", computedPackageName.get());
    applicationName.set("#My $AppLICATION");
    assertEquals("com.allcaps.test.myapplication", computedPackageName.get());
}
Also used : DomainToPackageExpression(com.android.tools.idea.npw.project.DomainToPackageExpression) StringProperty(com.android.tools.idea.ui.properties.core.StringProperty) StringValueProperty(com.android.tools.idea.ui.properties.core.StringValueProperty) Test(org.junit.Test)

Example 4 with StringValueProperty

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

the class BindingsManagerTest method releaseAllDisconnectsTwoWayBindings.

@Test
public void releaseAllDisconnectsTwoWayBindings() throws Exception {
    BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
    StringValueProperty property1 = new StringValueProperty("First");
    StringValueProperty property2 = new StringValueProperty("Second");
    bindings.bindTwoWay(property1, property2);
    assertThat(property1.get()).isEqualTo("Second");
    bindings.releaseAll();
    property1.set("Property1");
    assertThat(property2.get()).isEqualTo("Second");
    property2.set("Property2");
    assertThat(property1.get()).isEqualTo("Property1");
}
Also used : StringValueProperty(com.android.tools.idea.ui.properties.core.StringValueProperty) Test(org.junit.Test)

Example 5 with StringValueProperty

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

the class BindingsManagerTest method releaseAllDisconnectsOneWayBindings.

@Test
public void releaseAllDisconnectsOneWayBindings() throws Exception {
    BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
    StringValueProperty property1 = new StringValueProperty("A");
    StringValueProperty property2 = new StringValueProperty("B");
    bindings.bind(property1, property2);
    assertThat(property1.get()).isEqualTo("B");
    bindings.releaseAll();
    property2.set("Property2");
    assertThat(property1.get()).isEqualTo("B");
}
Also used : StringValueProperty(com.android.tools.idea.ui.properties.core.StringValueProperty) 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