use of com.android.tools.idea.ui.properties.core.StringValueProperty in project android by JetBrains.
the class BindingsManagerTest method releaseTwoWayDisconnectsTwoWayBindings.
@Test
public void releaseTwoWayDisconnectsTwoWayBindings() 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.releaseTwoWay(property1, property2);
property1.set("Property1");
assertThat(property2.get()).isEqualTo("Second");
property2.set("Property2");
assertThat(property1.get()).isEqualTo("Property1");
}
use of com.android.tools.idea.ui.properties.core.StringValueProperty in project android by JetBrains.
the class BindingsManagerTest method releaseDisconnectsOneWayBindings.
@Test
public void releaseDisconnectsOneWayBindings() 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.release(property1);
property2.set("Property2");
assertThat(property1.get()).isEqualTo("B");
}
use of com.android.tools.idea.ui.properties.core.StringValueProperty in project android by JetBrains.
the class DeveloperServiceCreator method createContext.
@NotNull
private static ServiceContext createContext(@NotNull Module module) {
String buildSystemId = getBuildSystemOperations(module.getProject()).getBuildSystemId();
ServiceContext context = new ServiceContext(buildSystemId);
String packageName = MergedManifest.get(module).getPackage();
if (packageName != null) {
context.putValue("packageName", new StringValueProperty(packageName));
}
AndroidPlatform platform = AndroidPlatform.getInstance(module);
if (platform != null) {
// Add the compileSdkVersion (or buildApiVersion) such that compatible dependencies are chosen
AndroidVersion version = platform.getApiVersion();
context.putValue(ATTR_BUILD_API, new IntValueProperty(version.getFeatureLevel()));
context.putValue(ATTR_BUILD_API_STRING, new StringValueProperty(getBuildApiString(version)));
}
return context;
}
use of com.android.tools.idea.ui.properties.core.StringValueProperty 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");
}
use of com.android.tools.idea.ui.properties.core.StringValueProperty in project android by JetBrains.
the class StringExpressionsTest method testTrimExpression.
@Test
public void testTrimExpression() throws Exception {
StringValueProperty srcValue = new StringValueProperty();
StringValueProperty destValue = new StringValueProperty();
BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
bindings.bind(destValue, srcValue.trim());
assertThat(destValue.get()).isEmpty();
srcValue.set(" Preceded by whitespace");
assertThat(destValue.get()).isEqualTo("Preceded by whitespace");
srcValue.set(" Surrounded by whitespace ");
assertThat(destValue.get()).isEqualTo("Surrounded by whitespace");
srcValue.set(" ");
assertThat(destValue.get()).isEmpty();
srcValue.set(" \t \n ");
assertThat(destValue.get()).isEmpty();
}
Aggregations