Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEd Merks2019-09-25 06:58:25 -0400
committerEd Merks2019-09-25 07:55:03 -0400
commit4612f71d7cfcb1171a36dc49b3eec1bfc8b94218 (patch)
tree13643ddc20437b414d59cc146ca252af3862e6bd /tests
parent2822ec713a601487babebbb3950746a13446ca61 (diff)
downloadeclipse.platform.swt-4612f71d7cfcb1171a36dc49b3eec1bfc8b94218.tar.gz
eclipse.platform.swt-4612f71d7cfcb1171a36dc49b3eec1bfc8b94218.tar.xz
eclipse.platform.swt-4612f71d7cfcb1171a36dc49b3eec1bfc8b94218.zip
Bug 551438 - Fix files that have ended up with CRLF in the git
repository Change-Id: I0b73a52d66fc55656971ed0e78bd436d3e0bdecf Signed-off-by: Ed Merks <ed.merks@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests.cocoa/.settings/org.eclipse.m2e.core.prefs8
-rw-r--r--tests/org.eclipse.swt.tests.gtk/.settings/org.eclipse.m2e.core.prefs8
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug547093_LogoffStuck.java112
-rw-r--r--tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug543747_JvmCrash_Msctf.java286
-rw-r--r--tests/org.eclipse.swt.tests/ManualTests/org/eclipse/swt/tests/manual/Bug548982_TreeAddRemoveMany.java316
5 files changed, 365 insertions, 365 deletions
diff --git a/tests/org.eclipse.swt.tests.cocoa/.settings/org.eclipse.m2e.core.prefs b/tests/org.eclipse.swt.tests.cocoa/.settings/org.eclipse.m2e.core.prefs
index 14b697b7bb..f897a7f1cb 100644
--- a/tests/org.eclipse.swt.tests.cocoa/.settings/org.eclipse.m2e.core.prefs
+++ b/tests/org.eclipse.swt.tests.cocoa/.settings/org.eclipse.m2e.core.prefs
@@ -1,4 +1,4 @@
-activeProfiles=
-eclipse.preferences.version=1
-resolveWorkspaceProjects=true
-version=1
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/tests/org.eclipse.swt.tests.gtk/.settings/org.eclipse.m2e.core.prefs b/tests/org.eclipse.swt.tests.gtk/.settings/org.eclipse.m2e.core.prefs
index 14b697b7bb..f897a7f1cb 100644
--- a/tests/org.eclipse.swt.tests.gtk/.settings/org.eclipse.m2e.core.prefs
+++ b/tests/org.eclipse.swt.tests.gtk/.settings/org.eclipse.m2e.core.prefs
@@ -1,4 +1,4 @@
-activeProfiles=
-eclipse.preferences.version=1
-resolveWorkspaceProjects=true
-version=1
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug547093_LogoffStuck.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug547093_LogoffStuck.java
index 9effebffa8..c16a3dd49a 100644
--- a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug547093_LogoffStuck.java
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug547093_LogoffStuck.java
@@ -1,56 +1,56 @@
-/*******************************************************************************
- * Copyright (c) 2019 Syntevo and others. All rights reserved.
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- *
- * Contributors:
- * Syntevo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.tests.gtk.snippets;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-public class Bug547093_LogoffStuck {
- public static void main (String [] args) {
- Display display = new Display ();
-
- Shell shell = new Shell (display);
- shell.setLayout(new FillLayout());
- shell.setSize(300, 200);
-
- display.addListener(SWT.Dispose, event -> {
- /*
- * System.exit() prevents org.eclipse.swt.internal.SessionManagerDBus
- * from sending reply to session manager and it gets stuck waiting for
- * that reply.
- */
- System.exit(0);
- });
-
- final Label label = new Label(shell, SWT.WRAP | SWT.CENTER);
- label.setText("\n\n\nWhen you logoff, GNOME session manager will get stuck for 90 seconds");
-
- // Test for deadlock with shutdown hook on regular closing
- shell.addListener(SWT.Close, event -> {
- System.exit(0);
- });
-
- shell.open ();
-
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
-
- display.dispose ();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2019 Syntevo and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ *
+ * Contributors:
+ * Syntevo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug547093_LogoffStuck {
+ public static void main (String [] args) {
+ Display display = new Display ();
+
+ Shell shell = new Shell (display);
+ shell.setLayout(new FillLayout());
+ shell.setSize(300, 200);
+
+ display.addListener(SWT.Dispose, event -> {
+ /*
+ * System.exit() prevents org.eclipse.swt.internal.SessionManagerDBus
+ * from sending reply to session manager and it gets stuck waiting for
+ * that reply.
+ */
+ System.exit(0);
+ });
+
+ final Label label = new Label(shell, SWT.WRAP | SWT.CENTER);
+ label.setText("\n\n\nWhen you logoff, GNOME session manager will get stuck for 90 seconds");
+
+ // Test for deadlock with shutdown hook on regular closing
+ shell.addListener(SWT.Close, event -> {
+ System.exit(0);
+ });
+
+ shell.open ();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+
+ display.dispose ();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug543747_JvmCrash_Msctf.java b/tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug543747_JvmCrash_Msctf.java
index 7bed16d8ea..9e5f96f168 100644
--- a/tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug543747_JvmCrash_Msctf.java
+++ b/tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug543747_JvmCrash_Msctf.java
@@ -1,143 +1,143 @@
-/*******************************************************************************
- * Copyright (c) 2019 Syntevo and others. All rights reserved.
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- *
- * Contributors:
- * Syntevo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.tests.win32.snippets;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Bug543747_JvmCrash_Msctf {
- public static void reproduce526758(Shell parentShell) {
- Shell tempShell = new Shell(parentShell);
-
- // Create something to catch initial focus, so that
- // text.setFocus() does something. This is only to
- // show that .setFocus() is important.
- new Button(tempShell, SWT.PUSH);
-
- // This Text will cause crash.
- Text text = new Text(tempShell, 0);
-
- // Shell must be visible to prevent early return in .setFocus()
- tempShell.setSize(10, 10);
- tempShell.open();
-
- // ImmAssociateContext() itself is lazy.
- // .setFocus() causes it to start up.
- text.setFocus();
-
- // Destroying the shell triggers the bug.
- tempShell.dispose();
-
- // JVM still alive?
- MessageBox msgbox = new MessageBox(parentShell);
- msgbox.setMessage("Crash didn't reproduce");
- msgbox.open();
- }
-
- public static void reproduce543747(Shell parentShell) {
- Shell tempShell = new Shell(parentShell);
-
- // Create something to catch initial focus, so that
- // text.setFocus() does something. This is only to
- // show that .setFocus() is important.
- new Button(tempShell, SWT.PUSH);
-
- // This Text will cause crash.
- // Text needs to have an intermediate parent for this bug.
- Composite composite = new Composite(tempShell, 0);
- Text text = new Text(composite, 0);
-
- // Shell must be visible to prevent early return in .setFocus()
- tempShell.setSize(10, 10);
- tempShell.open();
-
- // ImmAssociateContext() itself is lazy.
- // .setFocus() causes it to start up.
- text.setFocus();
-
- // Destroying the shell triggers the bug.
- tempShell.dispose();
-
- // Give additional instructions
- MessageBox msgbox = new MessageBox(parentShell);
- msgbox.setMessage(
- "Now please do one of:\n" +
- "a) Open Task Manager, go to Users, right-click your user, select Disconnect, log in again\n" +
- "b) Connect Remote Desktop to this machine\n" +
- "\n" +
- "The snippet is expected to crash just after that."
- );
- msgbox.open();
- }
-
- public static void main (String [] args) {
- Display display = new Display ();
-
- Shell shell = new Shell (display);
- RowLayout layout = new RowLayout(SWT.VERTICAL);
- layout.marginHeight = 10;
- layout.marginWidth = 10;
- layout.spacing = 10;
- shell.setLayout(layout);
-
- final Text labelInfo = new Text(shell, SWT.READ_ONLY | SWT.MULTI);
- labelInfo.setText(
- "Both of these crashes are only seen on Win10 1809+\n" +
- "\n" +
- "To reproduce reliably, use Application Verifier:\n" +
- "1) Install Application Verifier:\n" +
- "a) Download Windows SDK:\n" +
- " https://go.microsoft.com/fwlink/p/?LinkID=2033908\n" +
- "b) Install it, selecting Application Verifier. Other components are not required.\n" +
- "\n" +
- "2) Configure Application Verifier\n" +
- "a) Run 'Application Verifier (X64)' from Start menu.\n" +
- "b) Use File | Add application... to add java.exe\n" +
- "c) IMPORTANT: On the right pane, make sure that only 'Basics/Heaps' is selected.\n" +
- " JVM always crashes with 'Basics/Exceptions' and 'Basics/Memory'\n" +
- "d) Click 'Save'. You can close Application Verifier now\n" +
- " It will be active until you explicitly disable it.\n" +
- "e) Restart application once.\n" +
- "f) Note: applications run slower and consume more RAM under Application Verifier.\n" +
- "\n" +
- "3) Reproduce the problem\n" +
- "\n" +
- "4) Disable Application Verifier if you want\n" +
- "a) Keep it enabled it if you're ready to tolerate the slowness, but find more bugs\n" +
- "b) Go to Application Verifier again\n" +
- "c) Delete java.exe from the list.\n" +
- "d) Click Save.\n" +
- "e) There's no need to uninstall Application Verifier, but you can do that if you like."
- );
-
- final Button button526758 = new Button(shell, SWT.PUSH);
- button526758.setText("Reproduce crash 526758");
- button526758.addListener(SWT.Selection, event -> {reproduce526758(shell);});
-
- final Button button543747 = new Button(shell, SWT.PUSH);
- button543747.setText("Reproduce crash 543747");
- button543747.addListener(SWT.Selection, event -> {reproduce543747(shell);});
-
- shell.pack();
- shell.open();
-
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
-
- display.dispose ();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2019 Syntevo and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ *
+ * Contributors:
+ * Syntevo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.win32.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug543747_JvmCrash_Msctf {
+ public static void reproduce526758(Shell parentShell) {
+ Shell tempShell = new Shell(parentShell);
+
+ // Create something to catch initial focus, so that
+ // text.setFocus() does something. This is only to
+ // show that .setFocus() is important.
+ new Button(tempShell, SWT.PUSH);
+
+ // This Text will cause crash.
+ Text text = new Text(tempShell, 0);
+
+ // Shell must be visible to prevent early return in .setFocus()
+ tempShell.setSize(10, 10);
+ tempShell.open();
+
+ // ImmAssociateContext() itself is lazy.
+ // .setFocus() causes it to start up.
+ text.setFocus();
+
+ // Destroying the shell triggers the bug.
+ tempShell.dispose();
+
+ // JVM still alive?
+ MessageBox msgbox = new MessageBox(parentShell);
+ msgbox.setMessage("Crash didn't reproduce");
+ msgbox.open();
+ }
+
+ public static void reproduce543747(Shell parentShell) {
+ Shell tempShell = new Shell(parentShell);
+
+ // Create something to catch initial focus, so that
+ // text.setFocus() does something. This is only to
+ // show that .setFocus() is important.
+ new Button(tempShell, SWT.PUSH);
+
+ // This Text will cause crash.
+ // Text needs to have an intermediate parent for this bug.
+ Composite composite = new Composite(tempShell, 0);
+ Text text = new Text(composite, 0);
+
+ // Shell must be visible to prevent early return in .setFocus()
+ tempShell.setSize(10, 10);
+ tempShell.open();
+
+ // ImmAssociateContext() itself is lazy.
+ // .setFocus() causes it to start up.
+ text.setFocus();
+
+ // Destroying the shell triggers the bug.
+ tempShell.dispose();
+
+ // Give additional instructions
+ MessageBox msgbox = new MessageBox(parentShell);
+ msgbox.setMessage(
+ "Now please do one of:\n" +
+ "a) Open Task Manager, go to Users, right-click your user, select Disconnect, log in again\n" +
+ "b) Connect Remote Desktop to this machine\n" +
+ "\n" +
+ "The snippet is expected to crash just after that."
+ );
+ msgbox.open();
+ }
+
+ public static void main (String [] args) {
+ Display display = new Display ();
+
+ Shell shell = new Shell (display);
+ RowLayout layout = new RowLayout(SWT.VERTICAL);
+ layout.marginHeight = 10;
+ layout.marginWidth = 10;
+ layout.spacing = 10;
+ shell.setLayout(layout);
+
+ final Text labelInfo = new Text(shell, SWT.READ_ONLY | SWT.MULTI);
+ labelInfo.setText(
+ "Both of these crashes are only seen on Win10 1809+\n" +
+ "\n" +
+ "To reproduce reliably, use Application Verifier:\n" +
+ "1) Install Application Verifier:\n" +
+ "a) Download Windows SDK:\n" +
+ " https://go.microsoft.com/fwlink/p/?LinkID=2033908\n" +
+ "b) Install it, selecting Application Verifier. Other components are not required.\n" +
+ "\n" +
+ "2) Configure Application Verifier\n" +
+ "a) Run 'Application Verifier (X64)' from Start menu.\n" +
+ "b) Use File | Add application... to add java.exe\n" +
+ "c) IMPORTANT: On the right pane, make sure that only 'Basics/Heaps' is selected.\n" +
+ " JVM always crashes with 'Basics/Exceptions' and 'Basics/Memory'\n" +
+ "d) Click 'Save'. You can close Application Verifier now\n" +
+ " It will be active until you explicitly disable it.\n" +
+ "e) Restart application once.\n" +
+ "f) Note: applications run slower and consume more RAM under Application Verifier.\n" +
+ "\n" +
+ "3) Reproduce the problem\n" +
+ "\n" +
+ "4) Disable Application Verifier if you want\n" +
+ "a) Keep it enabled it if you're ready to tolerate the slowness, but find more bugs\n" +
+ "b) Go to Application Verifier again\n" +
+ "c) Delete java.exe from the list.\n" +
+ "d) Click Save.\n" +
+ "e) There's no need to uninstall Application Verifier, but you can do that if you like."
+ );
+
+ final Button button526758 = new Button(shell, SWT.PUSH);
+ button526758.setText("Reproduce crash 526758");
+ button526758.addListener(SWT.Selection, event -> {reproduce526758(shell);});
+
+ final Button button543747 = new Button(shell, SWT.PUSH);
+ button543747.setText("Reproduce crash 543747");
+ button543747.addListener(SWT.Selection, event -> {reproduce543747(shell);});
+
+ shell.pack();
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+
+ display.dispose ();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests/ManualTests/org/eclipse/swt/tests/manual/Bug548982_TreeAddRemoveMany.java b/tests/org.eclipse.swt.tests/ManualTests/org/eclipse/swt/tests/manual/Bug548982_TreeAddRemoveMany.java
index 16ee502bab..d72f592130 100644
--- a/tests/org.eclipse.swt.tests/ManualTests/org/eclipse/swt/tests/manual/Bug548982_TreeAddRemoveMany.java
+++ b/tests/org.eclipse.swt.tests/ManualTests/org/eclipse/swt/tests/manual/Bug548982_TreeAddRemoveMany.java
@@ -1,159 +1,159 @@
-/*******************************************************************************
- * Copyright (c) 2019 Syntevo 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:
- * Syntevo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.tests.manual;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public final class Bug548982_TreeAddRemoveMany {
- // Options
- // Java only
- private static boolean CREATE_CTOR_2PARAM = false;
- // Native & Java
- private static boolean LOCK_REDRAW = false;
- private static boolean CREATE_AFTER_EXPAND = false;
- private static boolean CREATE_REVERSE_ORDER = false;
- private static boolean DELETE_PARENT_ITEM = false;
- private static boolean DELETE_AFTER_COLLAPSE = false;
- private static int NUM_ITEMS = 20000;
-
- private static Tree tree;
- private static TreeItem rootItem;
- private static int iteration = 0;
-
- private static void CreateRootItem() {
- rootItem = new TreeItem(tree, SWT.NONE, 0);
- rootItem.setText("Root");
-
- CreateExpanderSubItem();
- }
-
- private static void CreateExpanderSubItem() {
- new TreeItem(rootItem, SWT.NONE);
- }
-
- private static void CreateTreeItems() {
- iteration++;
-
- final long start = System.currentTimeMillis();
-
- if (LOCK_REDRAW) {
- tree.setRedraw(false);
- }
-
- // Delete artificial item from 'CreateExpanderSubItem'
- rootItem.removeAll();
-
- if (CREATE_REVERSE_ORDER) {
- for (int i = NUM_ITEMS - 1; i >= 0; i--) {
- TreeItem child = new TreeItem(rootItem, SWT.NONE, 0);
- child.setText("Item:" + iteration + ":" + i);
- }
- } else {
- for (int i = 0; i < NUM_ITEMS; i++) {
- TreeItem child;
-
- if (CREATE_CTOR_2PARAM)
- child = new TreeItem(rootItem, SWT.NONE);
- else
- child = new TreeItem(rootItem, SWT.NONE, i);
-
- child.setText("Item:" + iteration + ":" + i);
- }
- }
-
- if (LOCK_REDRAW) {
- tree.setRedraw(true);
- }
-
- final long end = System.currentTimeMillis();
- System.out.println("CreateTreeItems: " + (end - start) + " ms");
- }
-
- private static void DeleteTreeItems() {
- final long start = System.currentTimeMillis();
-
- if (LOCK_REDRAW) {
- tree.setRedraw(false);
- }
-
- if (DELETE_PARENT_ITEM) {
- rootItem.dispose();
- CreateRootItem();
- } else {
- rootItem.removeAll();
- CreateExpanderSubItem();
- }
-
- if (LOCK_REDRAW) {
- tree.setRedraw(true);
- }
-
- final long end = System.currentTimeMillis();
- System.out.println("DeleteTreeItems: " + (end - start) + " ms");
- }
-
- public static void main(String[] args) {
- final Display display = new Display();
- final Shell shell = new Shell(display);
- shell.setLayout(new GridLayout());
- shell.setSize(800, 600);
-
- Label lblHint = new Label(shell, 0);
- lblHint.setText("Expand/collapse tree item. Timings will be printed to console. Various options are available in code near // Options.");
-
- tree = new Tree(shell, SWT.BORDER | SWT.VIRTUAL);
- tree.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
- final TreeColumn col = new TreeColumn(tree, SWT.NONE);
- col.setText("Column 1");
- col.setWidth(400);
-
- tree.addListener(SWT.Collapse, event -> {
- if (!DELETE_AFTER_COLLAPSE) {
- DeleteTreeItems();
- } else {
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- DeleteTreeItems();
- }
- });
- }
- });
-
- tree.addListener(SWT.Expand, event -> {
- if (!CREATE_AFTER_EXPAND) {
- CreateTreeItems();
- } else {
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- CreateTreeItems();
- }
- });
- }
- });
-
- CreateRootItem();
-
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- display.dispose();
- }
+/*******************************************************************************
+ * Copyright (c) 2019 Syntevo 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:
+ * Syntevo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.manual;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+public final class Bug548982_TreeAddRemoveMany {
+ // Options
+ // Java only
+ private static boolean CREATE_CTOR_2PARAM = false;
+ // Native & Java
+ private static boolean LOCK_REDRAW = false;
+ private static boolean CREATE_AFTER_EXPAND = false;
+ private static boolean CREATE_REVERSE_ORDER = false;
+ private static boolean DELETE_PARENT_ITEM = false;
+ private static boolean DELETE_AFTER_COLLAPSE = false;
+ private static int NUM_ITEMS = 20000;
+
+ private static Tree tree;
+ private static TreeItem rootItem;
+ private static int iteration = 0;
+
+ private static void CreateRootItem() {
+ rootItem = new TreeItem(tree, SWT.NONE, 0);
+ rootItem.setText("Root");
+
+ CreateExpanderSubItem();
+ }
+
+ private static void CreateExpanderSubItem() {
+ new TreeItem(rootItem, SWT.NONE);
+ }
+
+ private static void CreateTreeItems() {
+ iteration++;
+
+ final long start = System.currentTimeMillis();
+
+ if (LOCK_REDRAW) {
+ tree.setRedraw(false);
+ }
+
+ // Delete artificial item from 'CreateExpanderSubItem'
+ rootItem.removeAll();
+
+ if (CREATE_REVERSE_ORDER) {
+ for (int i = NUM_ITEMS - 1; i >= 0; i--) {
+ TreeItem child = new TreeItem(rootItem, SWT.NONE, 0);
+ child.setText("Item:" + iteration + ":" + i);
+ }
+ } else {
+ for (int i = 0; i < NUM_ITEMS; i++) {
+ TreeItem child;
+
+ if (CREATE_CTOR_2PARAM)
+ child = new TreeItem(rootItem, SWT.NONE);
+ else
+ child = new TreeItem(rootItem, SWT.NONE, i);
+
+ child.setText("Item:" + iteration + ":" + i);
+ }
+ }
+
+ if (LOCK_REDRAW) {
+ tree.setRedraw(true);
+ }
+
+ final long end = System.currentTimeMillis();
+ System.out.println("CreateTreeItems: " + (end - start) + " ms");
+ }
+
+ private static void DeleteTreeItems() {
+ final long start = System.currentTimeMillis();
+
+ if (LOCK_REDRAW) {
+ tree.setRedraw(false);
+ }
+
+ if (DELETE_PARENT_ITEM) {
+ rootItem.dispose();
+ CreateRootItem();
+ } else {
+ rootItem.removeAll();
+ CreateExpanderSubItem();
+ }
+
+ if (LOCK_REDRAW) {
+ tree.setRedraw(true);
+ }
+
+ final long end = System.currentTimeMillis();
+ System.out.println("DeleteTreeItems: " + (end - start) + " ms");
+ }
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+ shell.setSize(800, 600);
+
+ Label lblHint = new Label(shell, 0);
+ lblHint.setText("Expand/collapse tree item. Timings will be printed to console. Various options are available in code near // Options.");
+
+ tree = new Tree(shell, SWT.BORDER | SWT.VIRTUAL);
+ tree.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
+ final TreeColumn col = new TreeColumn(tree, SWT.NONE);
+ col.setText("Column 1");
+ col.setWidth(400);
+
+ tree.addListener(SWT.Collapse, event -> {
+ if (!DELETE_AFTER_COLLAPSE) {
+ DeleteTreeItems();
+ } else {
+ display.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ DeleteTreeItems();
+ }
+ });
+ }
+ });
+
+ tree.addListener(SWT.Expand, event -> {
+ if (!CREATE_AFTER_EXPAND) {
+ CreateTreeItems();
+ } else {
+ display.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ CreateTreeItems();
+ }
+ });
+ }
+ });
+
+ CreateRootItem();
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
} \ No newline at end of file

Back to the top