use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObjectPropertyTest method testInvalidationListenerFiredOnValueChange.
@Test
public void testInvalidationListenerFiredOnValueChange() {
Person personA = new Person("John Doe", 25);
Person personB = new Person("Jane Doe", 21);
Person cloneB = new Person("Jane Doe", 21);
CountListener listener = new CountListener();
ObjectProperty<Person> personProperty = new ObjectValueProperty<>(personA);
personProperty.addListener(listener);
assertThat(listener.getCount()).isEqualTo(0);
personProperty.set(personB);
assertThat(listener.getCount()).isEqualTo(1);
personProperty.set(cloneB);
assertThat(listener.getCount()).isEqualTo(1);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class OptionalPropertyTest method testInvalidationListenerFiredOnValueChange.
@Test
public void testInvalidationListenerFiredOnValueChange() {
OptionalProperty<String> optStringValue = OptionalValueProperty.absent();
CountListener listener = new CountListener();
optStringValue.addListener(listener);
assertThat(listener.getCount()).isEqualTo(0);
optStringValue.setValue("Text");
assertThat(listener.getCount()).isEqualTo(1);
optStringValue.setValue("Text");
assertThat(listener.getCount()).isEqualTo(1);
optStringValue.clear();
assertThat(listener.getCount()).isEqualTo(2);
optStringValue.clear();
assertThat(listener.getCount()).isEqualTo(2);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class StringValuePropertyTest method testInvalidationListenerFiredOnValueChange.
@Test
public void testInvalidationListenerFiredOnValueChange() {
StringValueProperty stringValue = new StringValueProperty();
CountListener listener = new CountListener();
stringValue.addListener(listener);
assertThat(listener.getCount()).isEqualTo(0);
stringValue.set("Text");
assertThat(listener.getCount()).isEqualTo(1);
stringValue.set("Text");
assertThat(listener.getCount()).isEqualTo(1);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObservableListTest method listInvalidatedOnClear.
@Test
public void listInvalidatedOnClear() throws Exception {
ObservableList<String> list = new ObservableList<>();
CountListener listener = new CountListener();
list.addListener(listener);
list.add("A");
assertThat(listener.getCount()).isEqualTo(1);
list.clear();
assertThat(listener.getCount()).isEqualTo(2);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObservableListTest method setAllReplacesTheCurrentList.
@Test
public void setAllReplacesTheCurrentList() throws Exception {
ObservableList<Integer> numericList = new ObservableList<>();
numericList.add(1);
numericList.add(2);
numericList.add(3);
CountListener listener = new CountListener();
numericList.addListener(listener);
numericList.setAll(Arrays.asList(10, 9, 8));
assertThat(numericList).containsExactly(10, 9, 8);
assertThat(listener.getCount()).isEqualTo(1);
}
Aggregations