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