blob: ca361d5e37bd39a214308ce506e0149f2fd67285 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2008 Matthew Hall and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Matthew Hall - initial API and implementation (bug 208332)
* Matthew Hall - bug 213145
* (through ProxyObservableListTest.java)
* Matthew Hall - bug 237718
******************************************************************************/
package org.eclipse.core.tests.databinding.observable.list;
import java.util.ArrayList;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.list.DecoratingObservableList;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.jface.databinding.conformance.MutableObservableListContractTest;
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
/**
* @since 3.2
*
*/
public class DecoratingObservableListTest {
public static Test suite() {
TestSuite suite = new TestSuite(DecoratingObservableListTest.class
.getName());
suite.addTest(MutableObservableListContractTest.suite(new Delegate()));
return suite;
}
static class Delegate extends AbstractObservableCollectionContractDelegate {
private Object elementType = Object.class;
public IObservableCollection createObservableCollection(Realm realm,
int elementCount) {
IObservableList wrappedList = new WritableList(realm,
new ArrayList(), elementType);
for (int i = 0; i < elementCount; i++)
wrappedList.add(new Object());
return new DecoratingObservableListStub(wrappedList);
}
public Object createElement(IObservableCollection collection) {
return new Object();
}
public Object getElementType(IObservableCollection collection) {
return elementType;
}
public void change(IObservable observable) {
((DecoratingObservableListStub) observable).decorated
.add(new Object());
}
}
static class DecoratingObservableListStub extends DecoratingObservableList {
IObservableList decorated;
DecoratingObservableListStub(IObservableList decorated) {
super(decorated, true);
this.decorated = decorated;
}
}
}