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.jface.tests.databinding;
11:
12: import junit.framework.TestCase;
13:
14: import org.eclipse.core.databinding.observable.Realm;
15: import org.eclipse.jface.databinding.swt.SWTObservables;
16: import org.eclipse.swt.widgets.Display;
17:
18: /**
19: * Base class that sets the default realm to be the SWT realm.
20: *
21: * @since 3.3
22: */
23: public class AbstractDefaultRealmTestCase extends TestCase {
24: private Realm previousRealm;
25:
26: /**
27: * Sets the default realm to be the realm for the default display.
28: *
29: * @see junit.framework.TestCase#setUp()
30: */
31: protected void setUp() throws Exception {
32: super .setUp();
33:
34: previousRealm = Realm.getDefault();
35:
36: Display display = Display.getCurrent() != null
37: && !Display.getCurrent().isDisposed() ? Display
38: .getCurrent() : Display.getDefault();
39: RealmTester.setDefault(SWTObservables.getRealm(display));
40: }
41:
42: /**
43: * Removes the default realm.
44: */
45: protected void tearDown() throws Exception {
46: super.tearDown();
47:
48: RealmTester.setDefault(previousRealm);
49: }
50: }
|