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");
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObservableListTest method listInvalidatedOnListIteratorSet.
@Test
public void listInvalidatedOnListIteratorSet() {
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.next();
iterator.set("X");
assertThat(list).containsExactly("A", "X", "C");
assertThat(listener.getCount()).isEqualTo(4);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class EditablePropertyTest method testEditableProperty.
@Test
public void testEditableProperty() {
JTextField field = new JTextField();
EditableProperty editableProperty = new EditableProperty(field);
CountListener listener = new CountListener();
editableProperty.addListener(listener);
assertThat(editableProperty.get()).isTrue();
assertThat(listener.getCount()).isEqualTo(0);
field.setEditable(false);
assertThat(editableProperty.get()).isFalse();
assertThat(listener.getCount()).isEqualTo(1);
editableProperty.set(true);
assertThat(field.isEditable()).isTrue();
assertThat(listener.getCount()).isEqualTo(2);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class EnabledPropertyTest method testEnabledProperty.
@Test
public void testEnabledProperty() {
JButton button = new JButton();
EnabledProperty enabledProperty = new EnabledProperty(button);
CountListener listener = new CountListener();
enabledProperty.addListener(listener);
assertThat(enabledProperty.get()).isTrue();
assertThat(listener.getCount()).isEqualTo(0);
button.setEnabled(false);
assertThat(enabledProperty.get()).isFalse();
assertThat(listener.getCount()).isEqualTo(1);
enabledProperty.set(true);
assertThat(button.isEnabled()).isTrue();
assertThat(listener.getCount()).isEqualTo(2);
}
Aggregations