use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObservableListTest method removeAllWithoutChangeDoesntFireInvalidation.
@Test
public void removeAllWithoutChangeDoesntFireInvalidation() throws Exception {
ObservableList<String> list = new ObservableList<>();
CountListener listener = new CountListener();
list.addListener(listener);
list.add("A");
list.add("B");
list.add("C");
assertThat(listener.getCount()).isEqualTo(3);
list.removeAll(ImmutableSet.of("X", "Y", "Z"));
assertThat(listener.getCount()).isEqualTo(3);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObservableListTest method listInvalidatedOnRemove.
@Test
public void listInvalidatedOnRemove() throws Exception {
ObservableList<String> list = new ObservableList<>();
CountListener listener = new CountListener();
list.addListener(listener);
assertThat(listener.getCount()).isEqualTo(0);
list.add("A");
list.add("B");
assertThat(listener.getCount()).isEqualTo(2);
list.remove(0);
assertThat(listener.getCount()).isEqualTo(3);
list.remove("B");
assertThat(listener.getCount()).isEqualTo(4);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObservableListTest method listInvalidatedOnIteratorRemove.
@Test
public void listInvalidatedOnIteratorRemove() {
ObservableList<String> list = new ObservableList<>();
CountListener listener = new CountListener();
list.addListener(listener);
list.add("A");
list.add("B");
list.add("C");
assertThat(listener.getCount()).isEqualTo(3);
Iterator<String> iterator = list.iterator();
iterator.next();
iterator.remove();
assertThat(list).containsExactly("B", "C");
assertThat(listener.getCount()).isEqualTo(4);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObservableListTest method retainAllWithoutChangeDoesntFireInvalidation.
@Test
public void retainAllWithoutChangeDoesntFireInvalidation() throws Exception {
ObservableList<String> list = new ObservableList<>();
CountListener listener = new CountListener();
list.addListener(listener);
list.add("A");
list.add("B");
list.add("C");
assertThat(listener.getCount()).isEqualTo(3);
list.retainAll(ImmutableSet.of("A", "B", "C"));
assertThat(listener.getCount()).isEqualTo(3);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObservableListTest method listInvalidatedOnAddAll.
@Test
public void listInvalidatedOnAddAll() throws Exception {
ObservableList<String> list = new ObservableList<>();
CountListener listener = new CountListener();
list.addListener(listener);
list.addAll(ImmutableSet.of("A", "B", "C"));
assertThat(listener.getCount()).isEqualTo(1);
assertThat(list).containsExactly("A", "B", "C");
}
Aggregations