01: /*******************************************************************************
02: * Copyright (c) 2007 Brad Reynolds and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Brad Reynolds - initial API and implementation
10: ******************************************************************************/package org.eclipse.core.tests.databinding.observable.set;
11:
12: import junit.framework.Test;
13: import junit.framework.TestCase;
14:
15: import org.eclipse.core.databinding.observable.IObservable;
16: import org.eclipse.core.databinding.observable.IObservableCollection;
17: import org.eclipse.core.databinding.observable.Realm;
18: import org.eclipse.core.databinding.observable.set.IObservableSet;
19: import org.eclipse.core.databinding.observable.set.UnionSet;
20: import org.eclipse.core.databinding.observable.set.WritableSet;
21: import org.eclipse.jface.conformance.databinding.AbstractObservableCollectionContractDelegate;
22: import org.eclipse.jface.conformance.databinding.ObservableCollectionContractTest;
23: import org.eclipse.jface.conformance.databinding.SuiteBuilder;
24:
25: /**
26: */
27: public class UnionSetTest extends TestCase {
28: public static Test suite() {
29: Delegate delegate = new Delegate();
30:
31: return new SuiteBuilder().addObservableContractTest(
32: ObservableCollectionContractTest.class, delegate)
33: .build();
34: }
35:
36: private static class Delegate extends
37: AbstractObservableCollectionContractDelegate {
38: private IObservableSet[] sets;
39:
40: private Delegate() {
41: }
42:
43: public void setUp() {
44:
45: super .setUp();
46: }
47:
48: public void tearDown() {
49: sets = null;
50:
51: super .tearDown();
52: }
53:
54: public void change(IObservable observable) {
55: sets[0].add(Integer.toString(sets[0].size()));
56: }
57:
58: public Object createElement(IObservableCollection collection) {
59: return Integer.toString(collection.size());
60: }
61:
62: public IObservableCollection createObservableCollection(
63: Realm realm, int elementCount) {
64: sets = new IObservableSet[] { new WritableSet(realm),
65: new WritableSet(realm) };
66:
67: IObservableSet set = new UnionSet(sets);
68:
69: for (int i = 0; i < elementCount; i++) {
70: sets[0].add(Integer.toString(i));
71: }
72:
73: return set;
74: }
75: }
76: }
|