diff --git a/bundles/org.eclipse.launchbar.ui.controls/META-INF/MANIFEST.MF b/bundles/org.eclipse.launchbar.ui.controls/META-INF/MANIFEST.MF index 77965c7a60d..393397e6fcb 100644 --- a/bundles/org.eclipse.launchbar.ui.controls/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.launchbar.ui.controls/META-INF/MANIFEST.MF @@ -19,4 +19,4 @@ Require-Bundle: org.eclipse.osgi.services;bundle-version="3.5.0", Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin -Export-Package: org.eclipse.launchbar.ui.controls.internal;x-internal:=true +Export-Package: org.eclipse.launchbar.ui.controls.internal;x-friends:="org.eclipse.launchbar.ui.tests" diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/CSelector.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/CSelector.java index cf18ca56d22..1b11aa03ea1 100644 --- a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/CSelector.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/CSelector.java @@ -264,6 +264,7 @@ public abstract class CSelector extends Composite { arrow.addMouseListener(mouseListener); if (editable) { final EditButton editButton = new EditButton(buttonComposite, SWT.NONE); + editButton.setData(LaunchBarWidgetIds.ID, LaunchBarWidgetIds.EDIT); editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true)); editButton.setBackground(getBackground()); editButton.addSelectionListener(new SelectionAdapter() { @@ -303,6 +304,7 @@ public abstract class CSelector extends Composite { popup.dispose(); } popup = new Shell(getShell(), SWT.TOOL | SWT.ON_TOP | SWT.RESIZE); + popup.setData(LaunchBarWidgetIds.ID, LaunchBarWidgetIds.POPUP); popup.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 0).create()); popup.setBackground(getBackground()); listViewer = new LaunchBarListViewer(popup); diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/ConfigSelector.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/ConfigSelector.java index a0107cdc858..41aa4ed4638 100644 --- a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/ConfigSelector.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/ConfigSelector.java @@ -51,6 +51,7 @@ public class ConfigSelector extends CSelector { public ConfigSelector(Composite parent, int style) { super(parent, style); + setData(LaunchBarWidgetIds.ID, LaunchBarWidgetIds.CONFIG_SELECTOR); setToolTipText(Messages.ConfigSelector_1); defaultProvider = new DefaultDescriptorLabelProvider(); @@ -166,6 +167,7 @@ public class ConfigSelector extends CSelector { @Override public void createActionArea(Composite parent) { final Composite createButton = new Composite(parent, SWT.BORDER); + createButton.setData(LaunchBarWidgetIds.ID, LaunchBarWidgetIds.NEW); GridDataFactory.fillDefaults().grab(true, false).applyTo(createButton); GridLayoutFactory.fillDefaults().margins(7, 7).applyTo(createButton); createButton.setBackground(getBackground()); @@ -230,9 +232,4 @@ public class ConfigSelector extends CSelector { super.setSelection(element); } - @Override - public void openPopup() { - super.openPopup(); - } - } diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarWidgetIds.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarWidgetIds.java new file mode 100644 index 00000000000..e749c29bddb --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarWidgetIds.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2017 QNX Software Systems 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 + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.launchbar.ui.controls.internal; + +public interface LaunchBarWidgetIds { + + public static final String ID = "org.eclipse.swtbot.widget.key"; //$NON-NLS-1$ + + public static final String CONFIG_SELECTOR = "org.eclipse.launchbar.selector.config"; //$NON-NLS-1$ + + public static final String POPUP = "org.eclipse.launchbar.popup"; //$NON-NLS-1$ + public static final String EDIT = "org.eclipse.launchbar.edit"; //$NON-NLS-1$ + public static final String NEW = "org.eclipse.launchbar.new"; //$NON-NLS-1$ + +} diff --git a/pom.xml b/pom.xml index 24172d34e3d..ae9f6fbf8d5 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,7 @@ platform - http://download.eclipse.org/eclipse/updates/4.6/ + http://download.eclipse.org/eclipse/updates/4.7/ p2 @@ -48,19 +48,24 @@ http://download.eclipse.org/cbi/updates/license/ p2 - + cdt - http://download.eclipse.org/tools/cdt/releases/9.0 + http://download.eclipse.org/tools/cdt/releases/9.2/ p2 remote - http://download.eclipse.org/tools/ptp/updates/remote/neon/ + http://download.eclipse.org/tools/ptp/builds/remote/oxygen/milestones/ + p2 + + + swtbot + http://download.eclipse.org/technology/swtbot/snapshots/ p2 @@ -71,6 +76,7 @@ bundles/org.eclipse.launchbar.ui.controls features/org.eclipse.launchbar tests/org.eclipse.launchbar.core.tests + tests/org.eclipse.launchbar.ui.tests bundles/org.eclipse.launchbar.remote.core bundles/org.eclipse.launchbar.remote.ui diff --git a/tests/org.eclipse.launchbar.ui.tests/.classpath b/tests/org.eclipse.launchbar.ui.tests/.classpath new file mode 100644 index 00000000000..eca7bdba8f0 --- /dev/null +++ b/tests/org.eclipse.launchbar.ui.tests/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/org.eclipse.launchbar.ui.tests/.project b/tests/org.eclipse.launchbar.ui.tests/.project new file mode 100644 index 00000000000..4883f55ece3 --- /dev/null +++ b/tests/org.eclipse.launchbar.ui.tests/.project @@ -0,0 +1,28 @@ + + + org.eclipse.launchbar.ui.tests + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/tests/org.eclipse.launchbar.ui.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.launchbar.ui.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0c68a61dca8 --- /dev/null +++ b/tests/org.eclipse.launchbar.ui.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/tests/org.eclipse.launchbar.ui.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.launchbar.ui.tests/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..16c10fa07a4 --- /dev/null +++ b/tests/org.eclipse.launchbar.ui.tests/META-INF/MANIFEST.MF @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Launch Bar UI Tests +Bundle-SymbolicName: org.eclipse.launchbar.ui.tests +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: Eclipse CDT +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.junit;bundle-version="4.12.0", + org.eclipse.swtbot.go;bundle-version="2.7.0", + org.eclipse.debug.core;bundle-version="3.11.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy +Import-Package: org.eclipse.launchbar.ui.controls.internal +Bundle-Activator: org.eclipse.launchbar.ui.tests.internal.Activator diff --git a/tests/org.eclipse.launchbar.ui.tests/build.properties b/tests/org.eclipse.launchbar.ui.tests/build.properties new file mode 100644 index 00000000000..34d2e4d2dad --- /dev/null +++ b/tests/org.eclipse.launchbar.ui.tests/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/tests/org.eclipse.launchbar.ui.tests/pom.xml b/tests/org.eclipse.launchbar.ui.tests/pom.xml new file mode 100644 index 00000000000..7442a5a8558 --- /dev/null +++ b/tests/org.eclipse.launchbar.ui.tests/pom.xml @@ -0,0 +1,44 @@ + + + 4.0.0 + + + org.eclipse.launchbar + 1.0.0-SNAPSHOT + ../../pom.xml + parent + + + org.eclipse.launchbar.ui.tests + 1.0.0-SNAPSHOT + eclipse-test-plugin + + + + + org.eclipse.tycho + tycho-surefire-plugin + ${tycho-version} + + + true + false + + **/AutomatedIntegrationSuite.* + + true + + + p2-installable-unit + org.eclipse.sdk.feature.group + + + org.eclipse.sdk.ide + + + + + + \ No newline at end of file diff --git a/tests/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/SWTBotCSelector.java b/tests/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/SWTBotCSelector.java new file mode 100644 index 00000000000..25b74498220 --- /dev/null +++ b/tests/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/SWTBotCSelector.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2017 QNX Software Systems 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 + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.launchbar.ui.tests; + +import org.eclipse.launchbar.ui.controls.internal.CSelector; +import org.eclipse.launchbar.ui.controls.internal.LaunchBarWidgetIds; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swtbot.swt.finder.SWTBot; +import org.eclipse.swtbot.swt.finder.SWTBotWidget; +import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; +import org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory; +import org.eclipse.swtbot.swt.finder.results.Result; +import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl; + +@SWTBotWidget(clasz = CSelector.class, preferredName = "cselector") +public class SWTBotCSelector extends AbstractSWTBotControl { + + public static SWTBotCSelector withId(String id) throws WidgetNotFoundException { + return new SWTBotCSelector(new SWTBot().widget(WidgetMatcherFactory.withId(id))); + } + + public SWTBotCSelector(CSelector w) throws WidgetNotFoundException { + super(w); + } + + public SWTBot bot() { + return new SWTBot(widget); + } + + public void click(int x, int y) { + notify(SWT.MouseEnter); + notify(SWT.MouseMove); + notify(SWT.Activate); + notify(SWT.FocusIn); + notify(SWT.MouseDown, createMouseEvent(x, y, 1, SWT.NONE, 1)); + notify(SWT.MouseUp, createMouseEvent(x, y, 1, SWT.BUTTON1, 1)); + } + + @Override + public SWTBotCSelector click() { + Point size = syncExec(new Result() { + @Override + public Point run() { + return widget.getSize(); + } + }); + click(size.x / 2, size.y / 2); + return this; + } + + public void clickEdit() { + bot().buttonWithId(LaunchBarWidgetIds.EDIT).click(); // $NON-NLS-1$ + } + + public void select(String text) { + click(); + } + +} diff --git a/tests/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/SWTBotConfigSelector.java b/tests/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/SWTBotConfigSelector.java new file mode 100644 index 00000000000..dfd28ad7bfe --- /dev/null +++ b/tests/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/SWTBotConfigSelector.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2017 QNX Software Systems 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 + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.launchbar.ui.tests; + +import org.eclipse.launchbar.ui.controls.internal.ConfigSelector; +import org.eclipse.launchbar.ui.controls.internal.LaunchBarWidgetIds; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swtbot.swt.finder.SWTBot; +import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; +import org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory; +import org.eclipse.swtbot.swt.finder.results.Result; +import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; + +@SuppressWarnings("nls") +public class SWTBotConfigSelector extends SWTBotCSelector { + + private class ActionArea extends AbstractSWTBotControl { + public ActionArea(SWTBotShell shell) throws WidgetNotFoundException { + super(shell.bot().widget(WidgetMatcherFactory.withId(LaunchBarWidgetIds.NEW))); + } + + public void click(int x, int y) { + notify(SWT.MouseEnter); + notify(SWT.MouseMove); + notify(SWT.Activate); + notify(SWT.FocusIn); + notify(SWT.MouseDown, createMouseEvent(x, y, 1, SWT.NONE, 1)); + notify(SWT.MouseUp, createMouseEvent(x, y, 1, SWT.BUTTON1, 1)); + } + + @Override + public ActionArea click() { + Point size = syncExec(new Result() { + @Override + public Point run() { + return widget.getSize(); + } + }); + click(size.x / 2, size.y / 2); + return this; + } + } + + public static class NewConfigDialog extends SWTBotShell { + public NewConfigDialog(Shell shell) { + super(shell); + } + + public NewConfigDialog setMode(String mode) { + bot().tableInGroup("Launch Mode").select(mode); + return this; + } + + public NewConfigDialog setType(String type) { + bot().tableInGroup("Launch Configuration Type").select(type); + return this; + } + + public NewConfigDialog next() { + bot().button("Next >").click(); + return this; + } + + public NewConfigDialog finish() { + bot().button("Finish").click(); + return this; + } + } + + public SWTBotConfigSelector(ConfigSelector configSelector) { + super(configSelector); + } + + public SWTBotConfigSelector(SWTBot bot) { + this(bot.widget(WidgetMatcherFactory.withId(LaunchBarWidgetIds.CONFIG_SELECTOR))); + } + + public NewConfigDialog newConfigDialog() { + click(); + new ActionArea(bot().shellWithId(LaunchBarWidgetIds.POPUP)).click(); + return new NewConfigDialog(bot().shell("Create Launch Configuration").widget); + } + +} diff --git a/tests/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/Activator.java b/tests/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/Activator.java new file mode 100644 index 00000000000..7b887ec433b --- /dev/null +++ b/tests/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/Activator.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2017 QNX Software Systems 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 + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.launchbar.ui.tests.internal; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; + +public class Activator extends AbstractUIPlugin { + + private static BundleContext bundleContext; + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + bundleContext = context; + } + + public static T getService(Class service) { + ServiceReference ref = bundleContext.getServiceReference(service); + return ref != null ? bundleContext.getService(ref) : null; + } + +} diff --git a/tests/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/AutomatedIntegrationSuite.java b/tests/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/AutomatedIntegrationSuite.java new file mode 100644 index 00000000000..26f656fcc2b --- /dev/null +++ b/tests/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/AutomatedIntegrationSuite.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright (c) 2017 QNX Software Systems 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 + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.launchbar.ui.tests.internal; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({ CreateLaunchConfigTests.class }) +public class AutomatedIntegrationSuite { + +} diff --git a/tests/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/CreateLaunchConfigTests.java b/tests/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/CreateLaunchConfigTests.java new file mode 100644 index 00000000000..7a952a28229 --- /dev/null +++ b/tests/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/CreateLaunchConfigTests.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2017 QNX Software Systems 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 + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.launchbar.ui.tests.internal; + +import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withPartName; + +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.launchbar.ui.tests.SWTBotConfigSelector; +import org.eclipse.launchbar.ui.tests.SWTBotConfigSelector.NewConfigDialog; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; +import org.eclipse.swtbot.swt.finder.SWTBot; +import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; +import org.eclipse.swtbot.swt.finder.waits.ICondition; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@SuppressWarnings("nls") +public class CreateLaunchConfigTests { + + private static SWTWorkbenchBot bot; + + @BeforeClass + public static void beforeClass() { + SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; + SWTBotPreferences.TIMEOUT = 10000; + bot = new SWTWorkbenchBot(); + } + + @Before + public void before() { + bot.resetWorkbench(); + + for (SWTBotView view : bot.views(withPartName("Welcome"))) { + view.close(); + } + } + + @Test + public void createEclipseApplication() throws Exception { + String configName = "Test Config"; + ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); + for (ILaunchConfiguration config : launchManager.getLaunchConfigurations()) { + if (config.getName().equals(configName)) { + config.delete(); + } + } + + bot.waitUntil(new ICondition() { + @Override + public void init(SWTBot bot) { + NewConfigDialog dialog = new SWTBotConfigSelector(bot).newConfigDialog(); + dialog.setMode("Debug").setType("Eclipse Application").next(); + dialog.bot().textWithLabel("Name:").setText(configName); + dialog.finish(); + } + + @Override + public boolean test() throws Exception { + for (ILaunchConfiguration config : launchManager.getLaunchConfigurations()) { + if (config.getName().equals(configName)) { + return true; + } + } + return false; + } + + @Override + public String getFailureMessage() { + return "Test config not found"; + } + }); + } + +}