diff options
author | Patrick Tasse | 2015-05-21 21:26:14 +0000 |
---|---|---|
committer | Patrick Tasse | 2015-05-27 17:33:22 +0000 |
commit | b1ba72397dc62f796e94fa1d96c7b2eb3a8e795f (patch) | |
tree | 9d7490157bbd9dce8a114badc2bd88fcdaa1734a | |
parent | 01d75563b39d5bc29cab430cb1d6ad705dee8a68 (diff) | |
download | org.eclipse.swtbot-b1ba72397dc62f796e94fa1d96c7b2eb3a8e795f.tar.gz org.eclipse.swtbot-b1ba72397dc62f796e94fa1d96c7b2eb3a8e795f.tar.xz org.eclipse.swtbot-b1ba72397dc62f796e94fa1d96c7b2eb3a8e795f.zip |
Support click() with modifiers in SWTBotToolbarButton
The method click(int) is added to the tool bar buttons to allow
simulating clicking a tool bar button while a key modifier is pressed.
Change-Id: I076ba45142ca226b09c25dc45eb8f88d84e17ab0
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
11 files changed, 115 insertions, 59 deletions
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButtonTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButtonTest.java index 55117105..1b7de571 100644 --- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButtonTest.java +++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButtonTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Ketan Padegaonkar and others. + * Copyright (c) 2008, 2015 Ketan Padegaonkar 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 @@ -8,17 +8,18 @@ * Contributors: * Ketan Padegaonkar - initial API and implementation * Ketan Padegaonkar - http://swtbot.org/bugzilla/show_bug.cgi?id=88 + * Patrick Tasse - support click with modifiers *******************************************************************************/ package org.eclipse.swtbot.swt.finder.widgets; import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.assertNotSameWidget; -import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.assertTextContains; import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.pass; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import java.util.List; +import org.eclipse.swt.SWT; import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; import org.eclipse.swtbot.swt.finder.test.AbstractControlExampleTest; import org.junit.Before; @@ -44,7 +45,19 @@ public class SWTBotToolbarDropDownButtonTest extends AbstractControlExampleTest bot.checkBox("Listen").select(); SWTBotToolbarDropDownButton button = bot.toolbarDropDownButton("Drop Down"); button.click(); - assertTextContains("Selection [13]: SelectionEvent{ToolItem ", bot.textInGroup("Listeners").widget); + assertEventMatches(bot.textInGroup("Listeners"), "Selection [13]: SelectionEvent{ToolItem {Drop Down} time=0 data=null item=null detail=0 x=0 y=0 width=0 height=0 stateMask=" + toStateMask(0, button.widget) + " text=null doit=true}"); + } finally { + bot.checkBox("Listen").deselect(); + } + } + + @Test + public void clicksToolBarButtonWithModifier() throws Exception { + try { + bot.checkBox("Listen").select(); + SWTBotToolbarDropDownButton button = bot.toolbarDropDownButton("Drop Down"); + button.click(SWT.SHIFT); + assertEventMatches(bot.textInGroup("Listeners"), "Selection [13]: SelectionEvent{ToolItem {Drop Down} time=0 data=null item=null detail=0 x=0 y=0 width=0 height=0 stateMask=" + toStateMask(SWT.SHIFT, button.widget) + " text=null doit=true}"); } finally { bot.checkBox("Listen").deselect(); } diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButtonWithToolTipTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButtonWithToolTipTest.java index 2c6e7b7d..600b9fb9 100644 --- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButtonWithToolTipTest.java +++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButtonWithToolTipTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Ketan Padegaonkar and others. + * Copyright (c) 2008, 2015 Ketan Padegaonkar 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 @@ -12,7 +12,6 @@ package org.eclipse.swtbot.swt.finder.widgets; import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.assertNotSameWidget; -import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.assertTextContains; import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.pass; import static org.junit.Assert.fail; @@ -30,8 +29,8 @@ public class SWTBotToolbarDropDownButtonWithToolTipTest extends AbstractControlE @Test public void findsToolBarButtonWithIndex() throws Exception { - SWTBotToolbarDropDownButton button0 = bot.toolbarDropDownButton("Drop Down"); - SWTBotToolbarDropDownButton button1 = bot.toolbarDropDownButton("Drop Down", 1); + SWTBotToolbarDropDownButton button0 = bot.toolbarDropDownButtonWithTooltip("SWT.DROP_DOWN"); + SWTBotToolbarDropDownButton button1 = bot.toolbarDropDownButtonWithTooltip("SWT.DROP_DOWN", 1); assertNotSameWidget(button0.widget, button1.widget); } @@ -39,9 +38,9 @@ public class SWTBotToolbarDropDownButtonWithToolTipTest extends AbstractControlE public void clicksToolBarButton() throws Exception { try { bot.checkBox("Listen").select(); - SWTBotToolbarDropDownButton button = bot.toolbarDropDownButton("Drop Down"); + SWTBotToolbarDropDownButton button = bot.toolbarDropDownButtonWithTooltip("SWT.DROP_DOWN"); button.click(); - assertTextContains("Selection [13]: SelectionEvent{ToolItem ", bot.textInGroup("Listeners").widget); + assertEventMatches(bot.textInGroup("Listeners"), "Selection [13]: SelectionEvent{ToolItem {} time=0 data=null item=null detail=0 x=0 y=0 width=0 height=0 stateMask=" + toStateMask(0, button.widget) + " text=null doit=true}"); } finally { bot.checkBox("Listen").deselect(); } diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarPushButtonTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarPushButtonTest.java index 4f01f380..df6cc920 100644 --- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarPushButtonTest.java +++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarPushButtonTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Ketan Padegaonkar and others. + * Copyright (c) 2008, 2015 Ketan Padegaonkar 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 @@ -7,16 +7,17 @@ * * Contributors: * Ketan Padegaonkar - initial API and implementation + * Patrick Tasse - support click with modifiers *******************************************************************************/ package org.eclipse.swtbot.swt.finder.widgets; import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.assertNotSameWidget; -import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.assertTextContains; import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.pass; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import org.eclipse.swt.SWT; import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; import org.eclipse.swtbot.swt.finder.results.VoidResult; @@ -81,9 +82,21 @@ public class SWTBotToolbarPushButtonTest extends AbstractControlExampleTest { public void clicksToolBarButton() throws Exception { try { bot.checkBox("Listen").select(); - SWTBotToolbarButton button = bot.toolbarButtonWithTooltip("SWT.PUSH"); + final SWTBotToolbarButton button = bot.toolbarButton("Push"); button.click(); - assertTextContains("Selection [13]: SelectionEvent{ToolItem ", bot.textInGroup("Listeners").widget); + assertEventMatches(bot.textInGroup("Listeners"), "Selection [13]: SelectionEvent{ToolItem {Push} time=0 data=null item=null detail=0 x=0 y=0 width=0 height=0 stateMask=" + toStateMask(0, button.widget) + " text=null doit=true}"); + } finally { + bot.checkBox("Listen").deselect(); + } + } + + @Test + public void clicksToolBarButtonWithModifier() throws Exception { + try { + bot.checkBox("Listen").select(); + final SWTBotToolbarButton button = bot.toolbarButton("Push"); + button.click(SWT.SHIFT); + assertEventMatches(bot.textInGroup("Listeners"), "Selection [13]: SelectionEvent{ToolItem {Push} time=0 data=null item=null detail=0 x=0 y=0 width=0 height=0 stateMask=" + toStateMask(SWT.SHIFT, button.widget) + " text=null doit=true}"); } finally { bot.checkBox("Listen").deselect(); } diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarRadioButtonTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarRadioButtonTest.java index 0a6be138..31f943b8 100644 --- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarRadioButtonTest.java +++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarRadioButtonTest.java @@ -7,13 +7,14 @@ * * Contributors: * Ketan Padegaonkar - initial API and implementation - * Patrick Tasse - fix click behavior + * Patrick Tasse - fix click behavior and support click with modifiers *******************************************************************************/ package org.eclipse.swtbot.swt.finder.widgets; import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.assertNotSameWidget; import static org.junit.Assert.assertTrue; +import org.eclipse.swt.SWT; import org.eclipse.swtbot.swt.finder.test.AbstractControlExampleTest; import org.junit.Before; import org.junit.Test; @@ -36,7 +37,14 @@ public class SWTBotToolbarRadioButtonTest extends AbstractControlExampleTest { public void clicksRadioButton() throws Exception { SWTBotToolbarRadioButton button = bot.toolbarRadioButton("Radio"); button.click(); - assertEventMatches(bot.textInGroup("Listeners"), "Selection [13]: SelectionEvent{ToolItem {Radio} time=-941780677 data=null item=null detail=0 x=0 y=0 width=0 height=0 stateMask=" + toStateMask(0, button.widget) + " text=null doit=true}"); + assertEventMatches(bot.textInGroup("Listeners"), "Selection [13]: SelectionEvent{ToolItem {Radio} time=0 data=null item=null detail=0 x=0 y=0 width=0 height=0 stateMask=" + toStateMask(0, button.widget) + " text=null doit=true}"); + } + + @Test + public void clicksRadioButtonWithModifier() throws Exception { + SWTBotToolbarRadioButton button = bot.toolbarRadioButton("Radio"); + button.click(SWT.SHIFT); + assertEventMatches(bot.textInGroup("Listeners"), "Selection [13]: SelectionEvent{ToolItem {Radio} time=0 data=null item=null detail=0 x=0 y=0 width=0 height=0 stateMask=" + toStateMask(SWT.SHIFT, button.widget) + " text=null doit=true}"); } @Test diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarToggleButtonTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarToggleButtonTest.java index 8deb9534..a62429b5 100644 --- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarToggleButtonTest.java +++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarToggleButtonTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Ketan Padegaonkar and others. + * Copyright (c) 2009, 2015 Ketan Padegaonkar 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 @@ -7,12 +7,14 @@ * * Contributors: * Ketan Padegaonkar - initial API and implementation + * Patrick Tasse - support click with modifiers *******************************************************************************/ package org.eclipse.swtbot.swt.finder.widgets; import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.assertNotSameWidget; import static org.junit.Assert.assertTrue; +import org.eclipse.swt.SWT; import org.eclipse.swtbot.swt.finder.test.AbstractControlExampleTest; import org.junit.Before; import org.junit.Test; @@ -35,7 +37,14 @@ public class SWTBotToolbarToggleButtonTest extends AbstractControlExampleTest { public void clicksCheckboxButton() throws Exception { SWTBotToolbarToggleButton button = bot.toolbarToggleButton("Check"); button.click(); - assertEventMatches(bot.textInGroup("Listeners"), "Selection [13]: SelectionEvent{ToolItem {Check} time=280949700 data=null item=null detail=0 x=0 y=0 width=0 height=0 stateMask=" + toStateMask(0, button.widget) + " text=null doit=true}\n"); + assertEventMatches(bot.textInGroup("Listeners"), "Selection [13]: SelectionEvent{ToolItem {Check} time=0 data=null item=null detail=0 x=0 y=0 width=0 height=0 stateMask=" + toStateMask(0, button.widget) + " text=null doit=true}\n"); + } + + @Test + public void clicksCheckboxButtonWithModifier() throws Exception { + SWTBotToolbarToggleButton button = bot.toolbarToggleButton("Check"); + button.click(SWT.SHIFT); + assertEventMatches(bot.textInGroup("Listeners"), "Selection [13]: SelectionEvent{ToolItem {Check} time=0 data=null item=null detail=0 x=0 y=0 width=0 height=0 stateMask=" + toStateMask(SWT.SHIFT, button.widget) + " text=null doit=true}\n"); } @Test diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarButton.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarButton.java index addba637..97ddffd8 100644 --- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarButton.java +++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarButton.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Ketan Padegaonkar and others. + * Copyright (c) 2008, 2015 Ketan Padegaonkar 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 @@ -7,6 +7,7 @@ * * Contributors: * Ketan Padegaonkar - initial API and implementation + * Patrick Tasse - support click with modifiers *******************************************************************************/ package org.eclipse.swtbot.swt.finder.widgets; @@ -48,22 +49,37 @@ public abstract class SWTBotToolbarButton extends AbstractSWTBot<ToolItem> { * * @since 1.0 */ - public abstract SWTBotToolbarButton click(); + public SWTBotToolbarButton click() { + return click(0); + } + + /** + * Click on the tool item with a particular state mask. + * + * @param stateMask the state of the keyboard modifier keys. + * + * @since 2.3 + */ + public abstract SWTBotToolbarButton click(int stateMask); protected void sendNotifications() { + sendNotifications(0); + } + + protected void sendNotifications(int stateMask) { notify(SWT.MouseEnter); notify(SWT.MouseMove); notify(SWT.Activate); notify(SWT.MouseDown); notify(SWT.MouseUp); - notify(SWT.Selection); + notify(SWT.Selection, createSelectionEvent(stateMask)); notify(SWT.MouseHover); notify(SWT.MouseMove); notify(SWT.MouseExit); notify(SWT.Deactivate); notify(SWT.FocusOut); } - + @Override public boolean isEnabled() { return syncExec(new BoolResult() { diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButton.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButton.java index b93b0d99..8ff5527e 100644 --- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButton.java +++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarDropDownButton.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008-2013 Ketan Padegaonkar and others. + * Copyright (c) 2008, 2015 Ketan Padegaonkar 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 @@ -9,6 +9,7 @@ * Ketan Padegaonkar - initial API and implementation * Ketan Padegaonkar - http://swtbot.org/bugzilla/show_bug.cgi?id=88 * Mickael Istria (Red Hat Inc.) - Bug 422458 + * Patrick Tasse - support click with modifiers *******************************************************************************/ package org.eclipse.swtbot.swt.finder.widgets; @@ -131,16 +132,12 @@ public class SWTBotToolbarDropDownButton extends SWTBotToolbarButton { } } - /** - * Click on the tool item. - * - * @since 1.0 - */ - public SWTBotToolbarDropDownButton click() { - log.debug(MessageFormat.format("Clicking on {0}", this)); //$NON-NLS-1$ + @Override + public SWTBotToolbarDropDownButton click(int stateMask) { + log.debug(MessageFormat.format("Clicking on {0}" + (stateMask != 0 ? " with stateMask=0x{1}" : ""), this, Integer.toHexString(stateMask))); //$NON-NLS-1$ waitForEnabled(); - sendNotifications(); - log.debug(MessageFormat.format("Clicked on {0}", this)); //$NON-NLS-1$ + sendNotifications(stateMask); + log.debug(MessageFormat.format("Clicked on {0}" + (stateMask != 0 ? " with stateMask=0x{1}" : ""), this, Integer.toHexString(stateMask))); //$NON-NLS-1$ return this; } diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarPushButton.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarPushButton.java index ea7594cf..b61f3816 100644 --- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarPushButton.java +++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarPushButton.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Obeo and others. + * Copyright (c) 2009, 2015 Obeo 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 @@ -7,6 +7,7 @@ * * Contributors: * Obeo - initial API and implementation + * Patrick Tasse - support click with modifiers *******************************************************************************/ package org.eclipse.swtbot.swt.finder.widgets; @@ -50,16 +51,12 @@ public class SWTBotToolbarPushButton extends SWTBotToolbarButton { Assert.isTrue(SWTUtils.hasStyle(w, SWT.PUSH), "Expecting a push button."); //$NON-NLS-1$ } - /** - * Click on the tool item. - * - * @since 1.0 - */ - public SWTBotToolbarPushButton click() { - log.debug(MessageFormat.format("Clicking on {0}", this)); //$NON-NLS-1$ + @Override + public SWTBotToolbarPushButton click(int stateMask) { + log.debug(MessageFormat.format("Clicking on {0}" + (stateMask != 0 ? " with stateMask=0x{1}" : ""), this, Integer.toHexString(stateMask))); //$NON-NLS-1$ waitForEnabled(); - sendNotifications(); - log.debug(MessageFormat.format("Clicked on {0}", this)); //$NON-NLS-1$ + sendNotifications(stateMask); + log.debug(MessageFormat.format("Clicked on {0}" + (stateMask != 0 ? " with stateMask=0x{1}" : ""), this, Integer.toHexString(stateMask))); //$NON-NLS-1$ return this; } } diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarRadioButton.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarRadioButton.java index 7bf3fede..a9e39e5c 100644 --- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarRadioButton.java +++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarRadioButton.java @@ -7,7 +7,7 @@ * * Contributors: * Ketan Padegaonkar - initial API and implementation - * Patrick Tasse - fix click behavior + * Patrick Tasse - fix click behavior and support click with modifiers *******************************************************************************/ package org.eclipse.swtbot.swt.finder.widgets; @@ -73,12 +73,12 @@ public class SWTBotToolbarRadioButton extends SWTBotToolbarButton { } @Override - public SWTBotToolbarRadioButton click() { - log.debug(MessageFormat.format("Clicking on {0}", this)); //$NON-NLS-1$ + public SWTBotToolbarRadioButton click(int stateMask) { + log.debug(MessageFormat.format("Clicking on {0}" + (stateMask != 0 ? " with stateMask=0x{1}" : ""), this, Integer.toHexString(stateMask))); //$NON-NLS-1$ waitForEnabled(); internalSetSelection(true); - sendNotifications(); - log.debug(MessageFormat.format("Clicked on {0}", this)); //$NON-NLS-1$ + sendNotifications(stateMask); + log.debug(MessageFormat.format("Clicked on {0}" + (stateMask != 0 ? " with stateMask=0x{1}" : ""), this, Integer.toHexString(stateMask))); //$NON-NLS-1$ return this; } diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarSeparatorButton.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarSeparatorButton.java index 11fdfd44..1584477d 100644 --- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarSeparatorButton.java +++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarSeparatorButton.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Obeo and others. + * Copyright (c) 2009, 2015 Obeo 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 @@ -7,6 +7,7 @@ * * Contributors: * Mariot Chauvin <mariot.chauvin@obeo.fr> - initial API and implementation + * Patrick Tasse - support click with modifiers *******************************************************************************/ package org.eclipse.swtbot.swt.finder.widgets; @@ -55,16 +56,12 @@ public class SWTBotToolbarSeparatorButton extends SWTBotToolbarButton { } - /** - * Click on the tool item. - * - * @since 2.0 - */ - public SWTBotToolbarSeparatorButton click() { - log.debug(MessageFormat.format("Clicking on {0}", this)); //$NON-NLS-1$ + @Override + public SWTBotToolbarSeparatorButton click(int stateMask) { + log.debug(MessageFormat.format("Clicking on {0}" + (stateMask != 0 ? " with stateMask=0x{1}" : ""), this, Integer.toHexString(stateMask))); //$NON-NLS-1$ waitForEnabled(); - sendNotifications(); - log.debug(MessageFormat.format("Clicked on {0}", this)); //$NON-NLS-1$ + sendNotifications(stateMask); + log.debug(MessageFormat.format("Clicked on {0}" + (stateMask != 0 ? " with stateMask=0x{1}" : ""), this, Integer.toHexString(stateMask))); //$NON-NLS-1$ return this; } } diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarToggleButton.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarToggleButton.java index e299dfef..36c05ed3 100644 --- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarToggleButton.java +++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotToolbarToggleButton.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Ketan Padegaonkar and others. + * Copyright (c) 2009, 2015 Ketan Padegaonkar 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 @@ -7,6 +7,7 @@ * * Contributors: * Ketan Padegaonkar - initial API and implementation + * Patrick Tasse - support click with modifiers *******************************************************************************/ package org.eclipse.swtbot.swt.finder.widgets; @@ -69,8 +70,14 @@ public class SWTBotToolbarToggleButton extends SWTBotToolbarButton { return this; } - public SWTBotToolbarToggleButton click() { - return toggle(); + @Override + public SWTBotToolbarToggleButton click(int stateMask) { + log.debug(MessageFormat.format("Clicking on {0}" + (stateMask != 0 ? " with stateMask=0x{1}" : ""), this, Integer.toHexString(stateMask))); //$NON-NLS-1$ + waitForEnabled(); + internalToggle(); + sendNotifications(stateMask); + log.debug(MessageFormat.format("Clicked on {0}" + (stateMask != 0 ? " with stateMask=0x{1}" : ""), this, Integer.toHexString(stateMask))); //$NON-NLS-1$ + return this; } private void internalToggle() { |