Search in sources :

Example 31 with CountListener

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

Example 32 with CountListener

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

Example 33 with CountListener

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

Example 34 with CountListener

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

Example 35 with CountListener

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