use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObservableListTest method listInvalidatedOnRemoveAll.
@Test
public void listInvalidatedOnRemoveAll() 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("A", "C"));
assertThat(listener.getCount()).isEqualTo(4);
assertThat(list).containsExactly("B");
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObservableListTest method beginUpdateCanBeCalledMultipleTimes.
@Test
public void beginUpdateCanBeCalledMultipleTimes() throws Exception {
ObservableList<String> list = new ObservableList<>();
CountListener listener = new CountListener();
list.addListener(listener);
list.beginUpdate();
list.beginUpdate();
list.beginUpdate();
assertThat(listener.getCount()).isEqualTo(0);
list.add("A");
list.add("B");
list.add("C");
assertThat(listener.getCount()).isEqualTo(0);
list.endUpdate();
assertThat(listener.getCount()).isEqualTo(0);
list.endUpdate();
assertThat(listener.getCount()).isEqualTo(0);
list.endUpdate();
assertThat(listener.getCount()).isEqualTo(1);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObservableListTest method listInvalidationDeferredIfUsingBeginEndUpdate.
@Test
public void listInvalidationDeferredIfUsingBeginEndUpdate() throws Exception {
ObservableList<String> list = new ObservableList<>();
CountListener listener = new CountListener();
list.addListener(listener);
list.beginUpdate();
assertThat(listener.getCount()).isEqualTo(0);
list.add("A");
list.add("B");
list.add("C");
assertThat(listener.getCount()).isEqualTo(0);
list.endUpdate();
assertThat(listener.getCount()).isEqualTo(1);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObservableListTest method listInvalidatedOnAdd.
@Test
public void listInvalidatedOnAdd() throws Exception {
ObservableList<String> list = new ObservableList<>();
CountListener listener = new CountListener();
list.addListener(listener);
assertThat(listener.getCount()).isEqualTo(0);
list.add("A");
assertThat(listener.getCount()).isEqualTo(1);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObservableListTest method listInvalidatedForEachElementAdded.
@Test
public void listInvalidatedForEachElementAdded() 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");
list.add("C");
assertThat(listener.getCount()).isEqualTo(3);
}
Aggregations