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();
}
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();
}
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();
}
Aggregations