diff options
| author | Stephane Bouchet | 2015-02-24 16:17:37 +0000 |
|---|---|---|
| committer | Mickael Istria | 2015-02-25 07:27:42 +0000 |
| commit | b181b0b6da7b59ebfccdc969f638ce47c0ebdcdf (patch) | |
| tree | fe848ed5d6fcdb163fe2be347687bd29e555bd08 | |
| parent | 075424d37b119acdf9736941bccdf104c492e800 (diff) | |
| download | org.eclipse.swtbot-b181b0b6da7b59ebfccdc969f638ce47c0ebdcdf.tar.gz org.eclipse.swtbot-b181b0b6da7b59ebfccdc969f638ce47c0ebdcdf.tar.xz org.eclipse.swtbot-b181b0b6da7b59ebfccdc969f638ce47c0ebdcdf.zip | |
[344484] SWTBotRadio method click() doesn't work properly
This change and associated test case fix the click() on radio button.
The test case is to select two radio on a preference page and verifies
the selection are correctly notified.
Change-Id: I068913c45d35bc5678656b4201819cf08a1d0420
Signed-off-by: Stephane Bouchet <stephane.bouchet@intel.com>
Bug: https://bugs.eclipse.org/344484
3 files changed, 88 insertions, 7 deletions
diff --git a/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/AllTests.java b/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/AllTests.java index 0e758e4d..4a12a963 100644 --- a/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/AllTests.java +++ b/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/AllTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008,2009,2010,2013 Ketan Padegaonkar and others. + * Copyright (c) 2008,2009,2010,2013,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,12 +8,14 @@ * Contributors: * Ketan Padegaonkar - initial API and implementation * Marcel Hoetter - added SWTBotToolbarContributionTest + * Stephane Bouchet (Intel Corporation) - added SWTBotEclipsePreferencesTest *******************************************************************************/ package org.eclipse.swtbot.eclipse.finder; import org.eclipse.swtbot.eclipse.finder.exceptions.QuickFixNotFoundExceptionTest; import org.eclipse.swtbot.eclipse.finder.finders.CommandFinderTest; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditorTest; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipsePreferencesTest; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseProjectTest; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotMultiPageEditorTest; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotToolbarContributionTest; @@ -34,6 +36,7 @@ import org.junit.runners.Suite.SuiteClasses; SWTBotEclipseEditorTest.class, SWTBotEclipseProjectTest.class, SWTBotMultiPageEditorTest.class, - SWTBotToolbarContributionTest.class}) + SWTBotToolbarContributionTest.class, + SWTBotEclipsePreferencesTest.class}) public class AllTests { } diff --git a/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotEclipsePreferencesTest.java b/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotEclipsePreferencesTest.java new file mode 100644 index 00000000..5de7df7a --- /dev/null +++ b/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotEclipsePreferencesTest.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2015 Stephane Bouchet (Intel Corporation). + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stephane Bouchet (Intel Corporation) - initial API and implementation + *******************************************************************************/ +package org.eclipse.swtbot.eclipse.finder.widgets; + +import static org.junit.Assert.assertTrue; + +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * @author Stephane Bouchet <stephane [dot] bouchet [at] intel [dot] com > + * @version $Id$ + */ +@RunWith(SWTBotJunit4ClassRunner.class) +public class SWTBotEclipsePreferencesTest { + + private static SWTWorkbenchBot bot = new SWTWorkbenchBot(); + + @BeforeClass + public static void beforeClass() { + closeWelcomePage(); + } + + private static void closeWelcomePage() { + try { + System.setProperty("org.eclipse.swtbot.search.timeout", "0"); + bot.viewByTitle("Welcome").close(); + } catch (WidgetNotFoundException e) { + // do nothing + } finally { + System.setProperty("org.eclipse.swtbot.search.timeout", "5000"); + } + } + + @Test + public void canSelectMultipleRadioInPreferencesWindow() { + // this will simply tries to change two radio in the team preferences at same times + bot.menu("Window").menu("Preferences").click(); + SWTBotShell prefsShell = bot.shell("Preferences"); + prefsShell.activate(); + bot.tree().getTreeItem("Team").select().click(); + bot.radioInGroup("Tree", "Choose the presentation to be used when displaying Workspace projects").click(); + bot.radioInGroup("Never", "Open the associated perspective when a synchronize operation completes").click(); + prefsShell.activate(); + SWTBotButton apply = bot.button("Apply"); + bot.waitUntil(org.eclipse.swtbot.swt.finder.waits.Conditions.widgetIsEnabled(apply)); + apply.click(); + SWTBotButton ok = bot.button("OK"); + bot.waitUntil(org.eclipse.swtbot.swt.finder.waits.Conditions.widgetIsEnabled(ok)); + ok.click(); + bot.waitUntil(org.eclipse.swtbot.swt.finder.waits.Conditions.shellCloses(prefsShell)); + bot.menu("Window").menu("Preferences").click(); + prefsShell = bot.shell("Preferences"); + prefsShell.activate(); + bot.tree().getTreeItem("Team").select().click(); + SWTBotRadio pref1 = bot.radioInGroup("Tree", "Choose the presentation to be used when displaying Workspace projects"); + SWTBotRadio pref2 = bot.radioInGroup("Never", "Open the associated perspective when a synchronize operation completes"); + assertTrue("Radio should be selected", pref1.isSelected()); + assertTrue("Radio should be selected", pref2.isSelected()); + } + +} diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotRadio.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotRadio.java index c3ee7d4b..a10c697e 100644 --- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotRadio.java +++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotRadio.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008,2010 Ketan Padegaonkar and others. + * Copyright (c) 2008,2010,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 + * Stephane Bouchet (Intel Corporation) - Bug 344484 *******************************************************************************/ package org.eclipse.swtbot.swt.finder.widgets; @@ -71,7 +72,7 @@ public class SWTBotRadio extends AbstractSWTBotControl<Button> { log.debug(MessageFormat.format("Clicking on {0}", this)); //$NON-NLS-1$ - final SWTBotRadio otherSelectedButton = otherSelectedButton(); + final SWTBotRadio otherSelectedButton=otherSelectedButton(); if (otherSelectedButton != null) { otherSelectedButton.notify(SWT.Deactivate); @@ -80,8 +81,10 @@ public class SWTBotRadio extends AbstractSWTBotControl<Button> { otherSelectedButton.widget.setSelection(false); } }); + otherSelectedButton.notify(SWT.Selection); } + setFocus(); notify(SWT.Activate); notify(SWT.MouseDown, createMouseEvent(0, 0, 1, 0, 1)); notify(SWT.MouseUp, createMouseEvent(0, 0, 1, SWT.BUTTON1, 1)); @@ -91,9 +94,7 @@ public class SWTBotRadio extends AbstractSWTBotControl<Button> { } }); notify(SWT.Selection); - if (otherSelectedButton != null) { - otherSelectedButton.notify(SWT.Selection); - } + log.debug(MessageFormat.format("Clicked on {0}", this)); //$NON-NLS-1$ return this; } |
