| /******************************************************************************* |
| * Copyright (c) 2008, 2009 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 215531) |
| * Matthew Hall - bug 213145 |
| * (through ObservableViewerElementSetTest.java) |
| * Matthew Hall - bug 262269 |
| ******************************************************************************/ |
| |
| package org.eclipse.core.tests.internal.databinding.observable; |
| |
| import junit.framework.Test; |
| import junit.framework.TestCase; |
| 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.set.IObservableSet; |
| import org.eclipse.core.internal.databinding.identity.IdentityObservableSet; |
| import org.eclipse.jface.databinding.conformance.MutableObservableSetContractTest; |
| import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate; |
| |
| public class IdentityObservableSetTest extends TestCase { |
| public static Test suite() { |
| TestSuite suite = new TestSuite(IdentityObservableSetTest.class |
| .getName()); |
| suite.addTest(MutableObservableSetContractTest.suite(new Delegate())); |
| return suite; |
| } |
| |
| private static class Delegate extends |
| AbstractObservableCollectionContractDelegate { |
| |
| public IObservableCollection createObservableCollection(Realm realm, |
| int elementCount) { |
| IdentityObservableSet set = new IdentityObservableSet(realm, |
| Object.class); |
| for (int i = 0; i < elementCount; i++) |
| set.add(createElement(set)); |
| return set; |
| } |
| |
| public Object createElement(IObservableCollection collection) { |
| return new Object(); |
| } |
| |
| public void change(IObservable observable) { |
| IObservableSet set = (IObservableSet) observable; |
| set.add(createElement(set)); |
| } |
| |
| public Object getElementType(IObservableCollection collection) { |
| return Object.class; |
| } |
| } |
| } |