Search in sources :

Example 26 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 27 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)

Example 28 with CountListener

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

Example 29 with CountListener

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

Example 30 with CountListener

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