01: /*******************************************************************************
02: * Copyright (c) 2006 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: * Ashley Cambrell - bug 198904
11: ******************************************************************************/package org.eclipse.jface.tests.internal.databinding.internal.swt;
12:
13: import org.eclipse.jface.internal.databinding.internal.swt.TableSingleSelectionObservableValue;
14: import org.eclipse.jface.tests.databinding.AbstractSWTTestCase;
15: import org.eclipse.swt.SWT;
16: import org.eclipse.swt.widgets.Table;
17: import org.eclipse.swt.widgets.TableItem;
18:
19: /**
20: * @since 3.2
21: */
22: public class TableObservableValueTest extends AbstractSWTTestCase {
23: public void testDispose() throws Exception {
24: Table table = new Table(getShell(), SWT.NONE);
25: TableSingleSelectionObservableValue observableValue = new TableSingleSelectionObservableValue(
26: table);
27:
28: TableItem item1 = new TableItem(table, SWT.NONE);
29: item1.setText("Item1");
30: TableItem item2 = new TableItem(table, SWT.NONE);
31: item2.setText("Item2");
32:
33: assertEquals(-1, table.getSelectionIndex());
34: assertEquals(-1, ((Integer) observableValue.getValue())
35: .intValue());
36:
37: table.select(0);
38: table.notifyListeners(SWT.Selection, null);
39:
40: assertEquals(0, table.getSelectionIndex());
41: assertEquals(new Integer(0), observableValue.getValue());
42:
43: observableValue.dispose();
44:
45: table.select(1);
46: table.notifyListeners(SWT.Selection, null);
47: assertEquals(1, table.getSelectionIndex());
48: }
49: }
|