Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-08-10 06:22:33 -0400
committerAlexander Kurtakov2017-08-11 01:43:42 -0400
commit1eabb1b2b0abefd1965ad52fc4515d6b99dfa361 (patch)
tree549ef94c17e9741338f49b439b6600dc6c762523 /tests
parent27adfd902a7ec245bdd989a091ad8d9d3c1c3bdc (diff)
downloadeclipse.platform.swt-1eabb1b2b0abefd1965ad52fc4515d6b99dfa361.tar.gz
eclipse.platform.swt-1eabb1b2b0abefd1965ad52fc4515d6b99dfa361.tar.xz
eclipse.platform.swt-1eabb1b2b0abefd1965ad52fc4515d6b99dfa361.zip
Bug 520822 - [api] Provide helpers to use lambda expressions for
MenuListener Add tests for the helper methods. Change-Id: Ifc7f5238a7d60e982d7560bddd3b853e993ecaae 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_Menu.java51
1 files changed, 50 insertions, 1 deletions
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Menu.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Menu.java
index 8a116c3653..48a661385f 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Menu.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Menu.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
@@ -154,6 +154,55 @@ public void test_addMenuListenerLorg_eclipse_swt_events_MenuListener() {
}
@Test
+public void test_addMenuListenerMenuShownAdapterLorg_eclipse_swt_events_MenuListener() {
+ MenuListener listener = MenuListener.menuShownAdapter(e -> listenerCalled = true);
+ menu.addMenuListener(listener);
+ listenerCalled = false;
+
+ menu.notifyListeners(SWT.Show, new Event());
+ assertTrue(listenerCalled);
+
+ listenerCalled = false;
+
+ menu.notifyListeners(SWT.Hide, new Event());
+ assertFalse(listenerCalled);
+
+ menu.removeMenuListener(listener);
+ listenerCalled = false;
+
+ menu.notifyListeners(SWT.Show, new Event());
+ assertFalse(listenerCalled);
+
+ menu.notifyListeners(SWT.Hide, new Event());
+ assertFalse(listenerCalled);
+}
+
+@Test
+public void test_addMenuListenerMenuHiddenAdapterLorg_eclipse_swt_events_MenuListener() {
+ MenuListener listener = MenuListener.menuHiddenAdapter(e -> listenerCalled = true);
+ menu.addMenuListener(listener);
+ listenerCalled = false;
+
+ menu.notifyListeners(SWT.Hide, new Event());
+ assertTrue(listenerCalled);
+
+ listenerCalled = false;
+
+ menu.notifyListeners(SWT.Show, new Event());
+ assertFalse(listenerCalled);
+
+ menu.removeMenuListener(listener);
+ listenerCalled = false;
+
+ menu.notifyListeners(SWT.Hide, new Event());
+ assertFalse(listenerCalled);
+
+ menu.notifyListeners(SWT.Show, new Event());
+ assertFalse(listenerCalled);
+}
+
+
+@Test
public void test_getItemCount() {
int number = 10;
for (int i = 0; i<number ; i++){

Back to the top