Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-08-11 04:47:20 -0400
committerAlexander Kurtakov2017-08-13 02:22:23 -0400
commit74f18e2641724761c41bab765de73e44fa540724 (patch)
tree5dfe805dee3a8ce91c3db5eb3c32383015ecaeb0 /tests
parent1ce6def3f7454ddb00da40925b2961584bf4b995 (diff)
downloadeclipse.platform.swt-74f18e2641724761c41bab765de73e44fa540724.tar.gz
eclipse.platform.swt-74f18e2641724761c41bab765de73e44fa540724.tar.xz
eclipse.platform.swt-74f18e2641724761c41bab765de73e44fa540724.zip
Bug 520884 - [api] Provide helpers to use lambda expressions for
MouseTrackListener Add tests. Change-Id: I9846addac996fedf6f975e651232f6c9e24af9f4 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_Control.java97
1 files changed, 97 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java
index 6a8e2837fa..0a8b0ae13d 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java
@@ -335,6 +335,103 @@ public void test_addMouseTrackListenerLorg_eclipse_swt_events_MouseTrackListener
assertTrue(eventOccurred);
control.removeMouseTrackListener(listener);
}
+
+@Test
+public void test_addMouseTrackListenerMouseEnterAdapterLorg_eclipse_swt_events_MouseTrackListener() {
+ MouseTrackListener listener = MouseTrackListener.mouseEnterAdapter(e -> eventOccurred = true);
+ control.addMouseTrackListener(listener);
+ eventOccurred = false;
+
+ control.notifyListeners(SWT.MouseEnter, new Event());
+ assertTrue(eventOccurred);
+
+ eventOccurred = false;
+
+ control.notifyListeners(SWT.MouseExit, new Event());
+ assertFalse(eventOccurred);
+
+ eventOccurred = false;
+
+ control.notifyListeners(SWT.MouseHover, new Event());
+ assertFalse(eventOccurred);
+
+ control.removeMouseTrackListener(listener);
+ eventOccurred = false;
+
+ control.notifyListeners(SWT.MouseEnter, new Event());
+ assertFalse(eventOccurred);
+
+ control.notifyListeners(SWT.MouseExit, new Event());
+ assertFalse(eventOccurred);
+
+ control.notifyListeners(SWT.MouseHover, new Event());
+ assertFalse(eventOccurred);
+}
+
+@Test
+public void test_addMouseTrackListenerMouseExitAdapterLorg_eclipse_swt_events_MouseTrackListener() {
+ MouseTrackListener listener = MouseTrackListener.mouseExitAdapter(e -> eventOccurred = true);
+ control.addMouseTrackListener(listener);
+ eventOccurred = false;
+
+ control.notifyListeners(SWT.MouseExit, new Event());
+ assertTrue(eventOccurred);
+
+ eventOccurred = false;
+
+ control.notifyListeners(SWT.MouseEnter, new Event());
+ assertFalse(eventOccurred);
+
+ eventOccurred = false;
+
+ control.notifyListeners(SWT.MouseHover, new Event());
+ assertFalse(eventOccurred);
+
+ control.removeMouseTrackListener(listener);
+ eventOccurred = false;
+
+ control.notifyListeners(SWT.MouseExit, new Event());
+ assertFalse(eventOccurred);
+
+ control.notifyListeners(SWT.MouseEnter, new Event());
+ assertFalse(eventOccurred);
+
+ control.notifyListeners(SWT.MouseHover, new Event());
+ assertFalse(eventOccurred);
+}
+
+@Test
+public void test_addMouseTrackListenerMouseHoverAdapterLorg_eclipse_swt_events_MouseTrackListener() {
+ MouseTrackListener listener = MouseTrackListener.mouseHoverAdapter(e -> eventOccurred = true);
+ control.addMouseTrackListener(listener);
+ eventOccurred = false;
+
+ control.notifyListeners(SWT.MouseHover, new Event());
+ assertTrue(eventOccurred);
+
+ eventOccurred = false;
+
+ control.notifyListeners(SWT.MouseEnter, new Event());
+ assertFalse(eventOccurred);
+
+ eventOccurred = false;
+
+ control.notifyListeners(SWT.MouseExit, new Event());
+ assertFalse(eventOccurred);
+
+ control.removeMouseTrackListener(listener);
+ eventOccurred = false;
+
+ control.notifyListeners(SWT.MouseHover, new Event());
+ assertFalse(eventOccurred);
+
+ control.notifyListeners(SWT.MouseEnter, new Event());
+ assertFalse(eventOccurred);
+
+ control.notifyListeners(SWT.MouseExit, new Event());
+ assertFalse(eventOccurred);
+}
+
@Test
public void test_addPaintListenerLorg_eclipse_swt_events_PaintListener() {
PaintListener listener = e -> eventOccurred = true;

Back to the top