use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObservableListTest method listInvalidatedOnListIteratorAdd.
@Test
public void listInvalidatedOnListIteratorAdd() {
ObservableList<String> list = new ObservableList<>();
CountListener listener = new CountListener();
list.addListener(listener);
list.add("A");
list.add("B");
list.add("D");
assertThat(listener.getCount()).isEqualTo(3);
ListIterator<String> iterator = list.listIterator(2);
iterator.add("C");
assertThat(list).containsExactly("A", "B", "C", "D");
assertThat(listener.getCount()).isEqualTo(4);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class BoolValuePropertyTest method testInvalidationListenerFiredOnValueChange.
@Test
public void testInvalidationListenerFiredOnValueChange() {
BoolValueProperty boolValue = new BoolValueProperty();
CountListener listener = new CountListener();
boolValue.addListener(listener);
assertThat(listener.getCount()).isEqualTo(0);
boolValue.set(true);
assertThat(listener.getCount()).isEqualTo(1);
boolValue.set(true);
assertThat(listener.getCount()).isEqualTo(1);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class IntValuePropertyTest method testInvalidationListenerFiredOnValueChange.
@Test
public void testInvalidationListenerFiredOnValueChange() {
IntValueProperty intValue = new IntValueProperty(0);
CountListener listener = new CountListener();
intValue.addListener(listener);
assertThat(listener.getCount()).isEqualTo(0);
intValue.set(10);
assertThat(listener.getCount()).isEqualTo(1);
intValue.set(10);
assertThat(listener.getCount()).isEqualTo(1);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class ObservableDoubleTest method testInvalidationListenerFiredOnValueChange.
@Test
public void testInvalidationListenerFiredOnValueChange() {
DoubleValueProperty doubleValue = new DoubleValueProperty(0.0);
CountListener listener = new CountListener();
doubleValue.addListener(listener);
assertThat(listener.getCount()).isEqualTo(0);
doubleValue.set(10.0);
assertThat(listener.getCount()).isEqualTo(1);
doubleValue.set(10.0);
assertThat(listener.getCount()).isEqualTo(1);
}
use of com.android.tools.idea.ui.properties.CountListener in project android by JetBrains.
the class SelectedIndexPropertyTest method testSelectedIndexProperty.
@Test
public void testSelectedIndexProperty() {
DefaultComboBoxModel model = new DefaultComboBoxModel();
model.addElement("A");
model.addElement("B");
model.addElement("C");
JComboBox comboBox = new JComboBox(model);
SelectedIndexProperty selectedIndexProperty = new SelectedIndexProperty(comboBox);
CountListener listener = new CountListener();
selectedIndexProperty.addListener(listener);
assertThat(selectedIndexProperty.get()).isEqualTo(0);
assertThat(listener.getCount()).isEqualTo(0);
comboBox.setSelectedIndex(2);
assertThat(selectedIndexProperty.get()).isEqualTo(2);
assertThat(listener.getCount()).isEqualTo(1);
selectedIndexProperty.set(1);
assertThat(comboBox.getSelectedIndex()).isEqualTo(1);
assertThat(listener.getCount()).isEqualTo(2);
}
Aggregations