Search in sources :

Example 6 with ListChangeEventTracker

use of org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker in project eclipse.platform.ui by eclipse-platform.

the class JavaBeanObservableListTest method testFiresListChangeEvents.

@Test
public void testFiresListChangeEvents() throws Exception {
    ListChangeEventTracker listener = new ListChangeEventTracker();
    list.addListChangeListener(listener);
    assertEquals(0, listener.count);
    bean.setList(Arrays.asList("value"));
    assertEquals(1, listener.count);
}
Also used : ListChangeEventTracker(org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker) Test(org.junit.Test) ObservableListContractTest(org.eclipse.jface.databinding.conformance.ObservableListContractTest) MutableObservableListContractTest(org.eclipse.jface.databinding.conformance.MutableObservableListContractTest)

Example 7 with ListChangeEventTracker

use of org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker in project eclipse.platform.ui by eclipse-platform.

the class JavaBeanObservableListTest method testRemoveListChangeEvent.

@Test
public void testRemoveListChangeEvent() throws Exception {
    String element = "1";
    list.add(element);
    assertEquals(1, list.size());
    ListChangeEventTracker listener = new ListChangeEventTracker();
    list.addListChangeListener(listener);
    list.remove(element);
    assertEquals(1, listener.count);
    ListChangeEvent event = listener.event;
    assertSame(list, event.getObservableList());
    assertDiff(event.diff, Collections.singletonList("1"), Collections.EMPTY_LIST);
}
Also used : ListChangeEvent(org.eclipse.core.databinding.observable.list.ListChangeEvent) ListChangeEventTracker(org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker) Test(org.junit.Test) ObservableListContractTest(org.eclipse.jface.databinding.conformance.ObservableListContractTest) MutableObservableListContractTest(org.eclipse.jface.databinding.conformance.MutableObservableListContractTest)

Example 8 with ListChangeEventTracker

use of org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker in project eclipse.platform.ui by eclipse-platform.

the class JavaBeanObservableArrayBasedListTest method testSetListChangeEvent.

@Test
public void testSetListChangeEvent() throws Exception {
    String oldElement = "old";
    String newElement = "new";
    list.add(oldElement);
    ListChangeEventTracker listener = new ListChangeEventTracker();
    list.addListChangeListener(listener);
    assertEquals(0, listener.count);
    list.set(0, newElement);
    assertEquals(1, listener.count);
    ListChangeEvent event = listener.event;
    assertSame(list, event.getObservableList());
    assertDiff(event.diff, Collections.singletonList(oldElement), Collections.singletonList(newElement));
}
Also used : ListChangeEvent(org.eclipse.core.databinding.observable.list.ListChangeEvent) ListChangeEventTracker(org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker) Test(org.junit.Test) ObservableListContractTest(org.eclipse.jface.databinding.conformance.ObservableListContractTest) MutableObservableListContractTest(org.eclipse.jface.databinding.conformance.MutableObservableListContractTest)

Example 9 with ListChangeEventTracker

use of org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker in project eclipse.platform.ui by eclipse-platform.

the class JavaBeanObservableArrayBasedListTest method testAddAtIndexListChangeEvent.

@Test
public void testAddAtIndexListChangeEvent() throws Exception {
    String element = "1";
    assertEquals(0, list.size());
    ListChangeEventTracker listener = new ListChangeEventTracker();
    list.addListChangeListener(listener);
    list.add(0, element);
    ListChangeEvent event = listener.event;
    assertDiff(event.diff, Collections.EMPTY_LIST, Collections.singletonList("1"));
}
Also used : ListChangeEvent(org.eclipse.core.databinding.observable.list.ListChangeEvent) ListChangeEventTracker(org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker) Test(org.junit.Test) ObservableListContractTest(org.eclipse.jface.databinding.conformance.ObservableListContractTest) MutableObservableListContractTest(org.eclipse.jface.databinding.conformance.MutableObservableListContractTest)

Example 10 with ListChangeEventTracker

use of org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker in project eclipse.platform.ui by eclipse-platform.

the class JavaBeanObservableArrayBasedListTest method testAddAllAtIndexListChangeEvent.

@Test
public void testAddAllAtIndexListChangeEvent() throws Exception {
    List elements = Arrays.asList(new String[] { "1", "2" });
    list.addAll(elements);
    ListChangeEventTracker listener = new ListChangeEventTracker();
    list.addListChangeListener(listener);
    assertEquals(0, listener.count);
    list.addAll(2, elements);
    assertEquals(1, listener.count);
    ListChangeEvent event = listener.event;
    assertSame(list, event.getObservableList());
    assertDiff(event.diff, Arrays.asList(new Object[] { "1", "2" }), Arrays.asList(new Object[] { "1", "2", "1", "2" }));
}
Also used : ListChangeEvent(org.eclipse.core.databinding.observable.list.ListChangeEvent) ArrayList(java.util.ArrayList) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList) List(java.util.List) ListChangeEventTracker(org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker) Test(org.junit.Test) ObservableListContractTest(org.eclipse.jface.databinding.conformance.ObservableListContractTest) MutableObservableListContractTest(org.eclipse.jface.databinding.conformance.MutableObservableListContractTest)

Aggregations

ListChangeEventTracker (org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker)37 Test (org.junit.Test)36 ObservableListContractTest (org.eclipse.jface.databinding.conformance.ObservableListContractTest)35 MutableObservableListContractTest (org.eclipse.jface.databinding.conformance.MutableObservableListContractTest)32 ListChangeEvent (org.eclipse.core.databinding.observable.list.ListChangeEvent)18 IObservableList (org.eclipse.core.databinding.observable.list.IObservableList)16 ArrayList (java.util.ArrayList)13 List (java.util.List)12 CurrentRealm (org.eclipse.jface.databinding.conformance.util.CurrentRealm)4 WritableList (org.eclipse.core.databinding.observable.list.WritableList)2 ListDetailValueObservableList (org.eclipse.core.internal.databinding.observable.masterdetail.ListDetailValueObservableList)2 SimplePerson (org.eclipse.jface.examples.databinding.model.SimplePerson)2 IObservablesListener (org.eclipse.core.databinding.observable.IObservablesListener)1 ListDiff (org.eclipse.core.databinding.observable.list.ListDiff)1 ListDiffEntry (org.eclipse.core.databinding.observable.list.ListDiffEntry)1 ChangeEventTracker (org.eclipse.jface.databinding.conformance.util.ChangeEventTracker)1