01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation 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: * IBM Corporation - initial API and implementation
10: ******************************************************************************/package org.eclipse.jface.conformance.databinding;
11:
12: import org.eclipse.core.databinding.observable.IObservable;
13: import org.eclipse.jface.databinding.swt.SWTObservables;
14: import org.eclipse.jface.tests.databinding.RealmTester.DelegatingRealm;
15: import org.eclipse.swt.widgets.Display;
16:
17: /**
18: * Mutability tests for IObservableValue for a SWT widget.
19: *
20: * <p>
21: * This class is experimental and can change at any time. It is recommended to
22: * not subclass or assume the test names will not change. The only API that is
23: * guaranteed to not change are the constructors. The tests will remain public
24: * and not final in order to allow for consumers to turn off a test if needed by
25: * subclassing.
26: * </p>
27: *
28: * @since 3.2
29: */
30: public class SWTMutableObservableValueContractTest extends
31: MutableObservableValueContractTest {
32: private IObservableValueContractDelegate delegate;
33:
34: public SWTMutableObservableValueContractTest(
35: IObservableValueContractDelegate delegate) {
36: this (null, delegate);
37: }
38:
39: /**
40: * @param testName
41: * @param delegate
42: */
43: public SWTMutableObservableValueContractTest(String testName,
44: IObservableValueContractDelegate delegate) {
45: super (testName, delegate);
46: this .delegate = delegate;
47: }
48:
49: /**
50: * Creates a new observable passing the realm for the current display.
51: */
52: protected IObservable doCreateObservable() {
53: Display display = Display.getCurrent();
54: if (display == null) {
55: display = new Display();
56: }
57: DelegatingRealm delegateRealm = new DelegatingRealm(
58: SWTObservables.getRealm(display));
59: delegateRealm.setCurrent(true);
60:
61: return delegate.createObservable(delegateRealm);
62: }
63: }
|