Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-08-10 08:03:29 -0400
committerAlexander Kurtakov2017-08-11 03:12:42 -0400
commit855f01fd5f0fa60ee3ed887890a202481766dcf2 (patch)
tree0a4b4b796ecc283ffa7394e8db6cf9e6a39ee784 /tests
parent9583bb220837807a23b917ad8280e1afa17b1b22 (diff)
downloadeclipse.platform.swt-855f01fd5f0fa60ee3ed887890a202481766dcf2.tar.gz
eclipse.platform.swt-855f01fd5f0fa60ee3ed887890a202481766dcf2.tar.xz
eclipse.platform.swt-855f01fd5f0fa60ee3ed887890a202481766dcf2.zip
Bug 520831 - [api] Provide helpers to use lambda expressions for
TreeListener Add tests. Change-Id: I9f17b21053e70834dd52d859e6352f8a1d5779f2 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java52
1 files changed, 51 insertions, 1 deletions
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java
index ebf789e15b..e175b8f1bc 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,8 +22,10 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.TreeListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;
@@ -674,6 +676,54 @@ public void test_showItemLorg_eclipse_swt_widgets_TreeItem() {
}
@Test
+public void test_addTreeListenerTreeCollapsedAdapterLorg_eclipse_swt_events_TreeListener() {
+ TreeListener listener = TreeListener.treeCollapsedAdapter(e -> eventOccurred = true);
+ tree.addTreeListener(listener);
+ eventOccurred = false;
+
+ tree.notifyListeners(SWT.Collapse, new Event());
+ assertTrue(eventOccurred);
+
+ eventOccurred = false;
+
+ tree.notifyListeners(SWT.Expand, new Event());
+ assertFalse(eventOccurred);
+
+ tree.removeTreeListener(listener);
+ eventOccurred = false;
+
+ tree.notifyListeners(SWT.Collapse, new Event());
+ assertFalse(eventOccurred);
+
+ tree.notifyListeners(SWT.Expand, new Event());
+ assertFalse(eventOccurred);
+}
+
+@Test
+public void test_addTreeListenerTreeExpandedAdapterLorg_eclipse_swt_events_TreeListener() {
+ TreeListener listener = TreeListener.treeExpandedAdapter(e -> eventOccurred = true);
+ tree.addTreeListener(listener);
+ eventOccurred = false;
+
+ tree.notifyListeners(SWT.Expand, new Event());
+ assertTrue(eventOccurred);
+
+ eventOccurred = false;
+
+ tree.notifyListeners(SWT.Collapse, new Event());
+ assertFalse(eventOccurred);
+
+ tree.removeTreeListener(listener);
+ eventOccurred = false;
+
+ tree.notifyListeners(SWT.Expand, new Event());
+ assertFalse(eventOccurred);
+
+ tree.notifyListeners(SWT.Collapse, new Event());
+ assertFalse(eventOccurred);
+}
+
+@Test
public void test_showSelection() {
TreeItem item;

Back to the top