Search in sources :

Example 11 with CountListener

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);
}
Also used : CountListener(com.android.tools.idea.ui.properties.CountListener) Test(org.junit.Test)

Example 12 with CountListener

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);
}
Also used : CountListener(com.android.tools.idea.ui.properties.CountListener) Test(org.junit.Test)

Example 13 with CountListener

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);
}
Also used : CountListener(com.android.tools.idea.ui.properties.CountListener) Test(org.junit.Test)

Example 14 with CountListener

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);
}
Also used : CountListener(com.android.tools.idea.ui.properties.CountListener) Test(org.junit.Test)

Example 15 with CountListener

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");
}
Also used : CountListener(com.android.tools.idea.ui.properties.CountListener) Test(org.junit.Test)

Aggregations

CountListener (com.android.tools.idea.ui.properties.CountListener)41 Test (org.junit.Test)41 LabelWithEditLink (com.android.tools.adtui.LabelWithEditLink)1 ColorPanel (com.intellij.ui.ColorPanel)1