Search in sources :

Example 6 with CountListener

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

Example 7 with CountListener

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

Example 8 with CountListener

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

Example 9 with CountListener

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

Example 10 with CountListener

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