Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEric Williams2019-10-17 14:49:46 -0400
committerEric Williams2019-10-17 15:52:17 -0400
commit01b6ec7f2b175a88e7d97b3e5187d84bdb831ce6 (patch)
tree341a0a0d3660ea43ff452a03d8fcfa3f40c28208 /tests
parent40e441871eef74946138b0ef8610d4c10efa48cc (diff)
downloadeclipse.platform.swt-01b6ec7f2b175a88e7d97b3e5187d84bdb831ce6.tar.gz
eclipse.platform.swt-01b6ec7f2b175a88e7d97b3e5187d84bdb831ce6.tar.xz
eclipse.platform.swt-01b6ec7f2b175a88e7d97b3e5187d84bdb831ce6.zip
Bug 552096: [GTK] Tree.showItem does not work reliably
Remove geometric calculations as they cannot be relied upon to be accurate. Just call gtk_tree_view_scroll_to_cell() directly as Table does. Tested on GTK3.24 and 3.10 using the snippet attached and a child Eclipse. No AllNonBrowser JUnit tests fail. Change-Id: I423943f349be63a637891e673ab4df34013c194c Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug552096_TreeShowItemUnreliable.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug552096_TreeShowItemUnreliable.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug552096_TreeShowItemUnreliable.java
new file mode 100644
index 0000000000..a924e5fd86
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug552096_TreeShowItemUnreliable.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Thomas Singer and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Thomas Singer - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug552096_TreeShowItemUnreliable {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+
+ final Button button = new Button(shell, SWT.PUSH);
+ button.setText("Add");
+ button.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+
+ final Tree tree = new Tree(shell, SWT.BORDER);
+ tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ button.addListener(SWT.Selection, event -> {
+ final TreeItem rootNode = new TreeItem(tree, SWT.NONE, 0);
+ // Code below appends to the bottom of the Tree
+// final TreeItem rootNode = new TreeItem(tree, SWT.NONE, tree.getItemCount());
+ rootNode.setText("Root " + tree.getItemCount());
+
+ final TreeItem childItem = new TreeItem(rootNode, SWT.NONE);
+ childItem.setText("Child");
+ rootNode.setExpanded(true);
+
+ tree.showItem(rootNode);
+ });
+
+ shell.setSize(400, 300);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+ }
+}

Back to the top