Search in sources :

Example 36 with CountListener

use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.

the class TextPropertyTest method textPropertyCanWrapLabelWithEditLink.

@Test
public void textPropertyCanWrapLabelWithEditLink() {
    LabelWithEditLink editLabel = new LabelWithEditLink();
    TextProperty textProperty = new TextProperty(editLabel);
    CountListener listener = new CountListener();
    textProperty.addListener(listener);
    assertThat(textProperty.get()).isEqualTo("");
    assertThat(listener.getCount()).isEqualTo(0);
    editLabel.setText("Edit label set directly");
    assertThat(textProperty.get()).isEqualTo("Edit label set directly");
    assertThat(listener.getCount()).isEqualTo(1);
    textProperty.set("Edit label updated via property");
    assertThat(editLabel.getText()).isEqualTo("Edit label updated via property");
    assertThat(listener.getCount()).isEqualTo(2);
}
Also used : LabelWithEditLink(com.android.tools.adtui.LabelWithEditLink) CountListener(com.android.tools.idea.ui.properties.CountListener) Test(org.junit.Test)

Example 37 with CountListener

use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.

the class ObservableListTest method listInvalidatedOnAddAllAtIndex.

@Test
public void listInvalidatedOnAddAllAtIndex() throws Exception {
    ObservableList<String> list = new ObservableList<>();
    CountListener listener = new CountListener();
    list.addListener(listener);
    list.add("A");
    list.add("D");
    assertThat(listener.getCount()).isEqualTo(2);
    list.addAll(1, ImmutableSet.of("B", "C"));
    assertThat(listener.getCount()).isEqualTo(3);
    assertThat(list).containsExactly("A", "B", "C", "D");
}
Also used : CountListener(com.android.tools.idea.ui.properties.CountListener) Test(org.junit.Test)

Example 38 with CountListener

use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.

the class ObservableListTest method clearOnEmptyListDoesntFireInvalidation.

@Test
public void clearOnEmptyListDoesntFireInvalidation() throws Exception {
    ObservableList<String> list = new ObservableList<>();
    CountListener listener = new CountListener();
    list.addListener(listener);
    list.clear();
    assertThat(listener.getCount()).isEqualTo(0);
}
Also used : CountListener(com.android.tools.idea.ui.properties.CountListener) Test(org.junit.Test)

Example 39 with CountListener

use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.

the class ObservableListTest method listInvalidatedOnListIteratorRemove.

@Test
public void listInvalidatedOnListIteratorRemove() {
    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);
    ListIterator<String> iterator = list.listIterator();
    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 40 with CountListener

use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.

the class ObservableListTest method listInvalidatedOnRetainAll.

@Test
public void listInvalidatedOnRetainAll() 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", "C"));
    assertThat(listener.getCount()).isEqualTo(4);
    assertThat(list).containsExactly("A", "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