diff --git a/launchbar/org.eclipse.launchbar.ui.tests/META-INF/MANIFEST.MF b/launchbar/org.eclipse.launchbar.ui.tests/META-INF/MANIFEST.MF index eae30467195..789df36a54b 100644 --- a/launchbar/org.eclipse.launchbar.ui.tests/META-INF/MANIFEST.MF +++ b/launchbar/org.eclipse.launchbar.ui.tests/META-INF/MANIFEST.MF @@ -1,17 +1,17 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName -Bundle-SymbolicName: org.eclipse.launchbar.ui.tests -Bundle-Version: 1.0.100.qualifier +Bundle-SymbolicName: org.eclipse.launchbar.ui.tests;singleton:=true +Bundle-Version: 1.1.0.qualifier Bundle-Vendor: %providerName 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" + org.eclipse.debug.core;bundle-version="3.18.300", + org.eclipse.debug.ui;bundle-version="3.15.200" Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-ActivationPolicy: lazy -Import-Package: org.eclipse.launchbar.ui.controls.internal -Bundle-Activator: org.eclipse.launchbar.ui.tests.internal.Activator +Import-Package: org.eclipse.launchbar.ui.controls.internal, + org.junit.jupiter.api;version="5.8.1" Automatic-Module-Name: org.eclipse.launchbar.ui.tests Bundle-Localization: plugin diff --git a/launchbar/org.eclipse.launchbar.ui.tests/build.properties b/launchbar/org.eclipse.launchbar.ui.tests/build.properties index 2b112c46131..1dde0d2c61c 100644 --- a/launchbar/org.eclipse.launchbar.ui.tests/build.properties +++ b/launchbar/org.eclipse.launchbar.ui.tests/build.properties @@ -3,5 +3,6 @@ output.. = bin/ bin.includes = META-INF/,\ .,\ plugin.properties,\ - about.html + about.html,\ + plugin.xml src.includes = about.html diff --git a/launchbar/org.eclipse.launchbar.ui.tests/plugin.xml b/launchbar/org.eclipse.launchbar.ui.tests/plugin.xml new file mode 100644 index 00000000000..9f94260993c --- /dev/null +++ b/launchbar/org.eclipse.launchbar.ui.tests/plugin.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/launchbar/org.eclipse.launchbar.ui.tests/pom.xml b/launchbar/org.eclipse.launchbar.ui.tests/pom.xml index b834ac40d3a..448ce1f69cd 100644 --- a/launchbar/org.eclipse.launchbar.ui.tests/pom.xml +++ b/launchbar/org.eclipse.launchbar.ui.tests/pom.xml @@ -22,7 +22,7 @@ org.eclipse.launchbar.ui.tests - 1.0.100-SNAPSHOT + 1.1.0-SNAPSHOT eclipse-test-plugin @@ -31,20 +31,14 @@ org.eclipse.tycho tycho-surefire-plugin - - true - false p2-installable-unit org.eclipse.pde.feature.group - org.eclipse.sdk.ide - ${tycho.testArgLine} ${base.ui.test.vmargs} - -pluginCustomization ${basedir}/../../disable_intro_in_tests.ini - \ No newline at end of file + diff --git a/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/SWTBotCSelector.java b/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/SWTBotCSelector.java index 15f64f45481..cea6f477bfe 100644 --- a/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/SWTBotCSelector.java +++ b/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/SWTBotCSelector.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2018 QNX Software Systems and others. + * Copyright (c) 2017, 2021 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -53,7 +53,7 @@ public class SWTBotCSelector extends AbstractSWTBotControl { } public void clickEdit() { - bot().buttonWithId(LaunchBarWidgetIds.EDIT).click(); // $NON-NLS-1$ + bot().canvasWithId(LaunchBarWidgetIds.EDIT).click(); } public void select(String text) { diff --git a/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/SWTBotConfigSelector.java b/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/SWTBotConfigSelector.java index 585ae41c9a9..27ec403c011 100644 --- a/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/SWTBotConfigSelector.java +++ b/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/SWTBotConfigSelector.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2018 QNX Software Systems and others. + * Copyright (c) 2017, 2021 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -73,6 +73,22 @@ public class SWTBotConfigSelector extends SWTBotCSelector { } } + public static class EditConfigDialog extends SWTBotShell { + public EditConfigDialog(Shell shell) { + super(shell); + } + + public EditConfigDialog selectTab(String tab) { + bot().cTabItem(tab).activate(); + return this; + } + + public EditConfigDialog ok() { + bot().button("OK").click(); + return this; + } + } + public SWTBotConfigSelector(ConfigSelector configSelector) { super(configSelector); } @@ -87,4 +103,8 @@ public class SWTBotConfigSelector extends SWTBotCSelector { return new NewConfigDialog(bot().shell("Create Launch Configuration").widget); } + public EditConfigDialog editConfigDialog() { + clickEdit(); + return new EditConfigDialog(bot().shell("Edit Configuration").widget); + } } diff --git a/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/Activator.java b/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/Activator.java deleted file mode 100644 index fc8dede9838..00000000000 --- a/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/Activator.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 QNX Software Systems and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - *******************************************************************************/ -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/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/AutomatedIntegrationSuite.java b/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/AutomatedIntegrationSuite.java deleted file mode 100644 index 5b5e4fe225f..00000000000 --- a/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/AutomatedIntegrationSuite.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 QNX Software Systems and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - *******************************************************************************/ -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/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/CreateLaunchConfigTests.java b/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/CreateLaunchConfigTests.java index be70b33b98d..026ddffe441 100644 --- a/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/CreateLaunchConfigTests.java +++ b/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/CreateLaunchConfigTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 QNX Software Systems and others. + * Copyright (c) 2017, 2021 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,33 +11,42 @@ package org.eclipse.launchbar.ui.tests.internal; import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withPartName; +import static org.junit.jupiter.api.Assertions.fail; +import java.util.concurrent.TimeUnit; + +import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.launchbar.ui.tests.SWTBotConfigSelector; +import org.eclipse.launchbar.ui.tests.SWTBotConfigSelector.EditConfigDialog; 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; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; public class CreateLaunchConfigTests { private static SWTWorkbenchBot bot; - @BeforeClass + @BeforeAll public static void beforeClass() { SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; SWTBotPreferences.TIMEOUT = 10000; bot = new SWTWorkbenchBot(); } - @Before + @BeforeEach public void before() { bot.resetWorkbench(); @@ -46,16 +55,25 @@ public class CreateLaunchConfigTests { } } - @Test - public void createEclipseApplication() throws Exception { - String configName = "Test Config"; + @AfterEach + public void after() { + // Delete created launch configs after we are done with them ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); - for (ILaunchConfiguration config : launchManager.getLaunchConfigurations()) { - if (config.getName().equals(configName)) { + try { + for (ILaunchConfiguration config : launchManager.getLaunchConfigurations()) { config.delete(); } + } catch (CoreException e) { + fail(e); } + } + @Test + @Timeout(value = 2, unit = TimeUnit.MINUTES) + public void createNewLaunchConfig() throws Exception { + String configName = "Test Config"; + + // Create config with launchbar bot.waitUntil(new ICondition() { @Override public void init(SWTBot bot) { @@ -67,6 +85,7 @@ public class CreateLaunchConfigTests { @Override public boolean test() throws Exception { + ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); for (ILaunchConfiguration config : launchManager.getLaunchConfigurations()) { if (config.getName().equals(configName)) { return true; @@ -82,4 +101,42 @@ public class CreateLaunchConfigTests { }); } + @Test + @Timeout(value = 2, unit = TimeUnit.MINUTES) + public void editExistingLaunchConfig() throws Exception { + // Create a launch config to edit + ILaunchConfigurationType type = DebugPlugin.getDefault().getLaunchManager() + .getLaunchConfigurationType("org.eclipse.pde.ui.RuntimeWorkbench"); + ILaunchConfigurationWorkingCopy wc = type.newInstance(null, "Test Config 2"); + wc.doSave(); + + // Edit config with launchbar + String configName = "Edited Config"; + bot.waitUntil(new ICondition() { + @Override + public void init(SWTBot bot) { + EditConfigDialog dialog = new SWTBotConfigSelector(bot).editConfigDialog(); + dialog.bot().textWithLabel("Launch Configuration Name:").setText(configName); + dialog.selectTab("Arguments"); + dialog.selectTab("My Custom Tab"); // See CustomLaunchConfigTab.java + dialog.ok(); + } + + @Override + public boolean test() throws Exception { + ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); + for (ILaunchConfiguration config : launchManager.getLaunchConfigurations()) { + if (config.getName().equals(configName)) { + return true; + } + } + return false; + } + + @Override + public String getFailureMessage() { + return "Unable to edit test config"; + } + }); + } } diff --git a/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/CustomLaunchConfigTab.java b/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/CustomLaunchConfigTab.java new file mode 100644 index 00000000000..aa4a67eee0d --- /dev/null +++ b/launchbar/org.eclipse.launchbar.ui.tests/src/org/eclipse/launchbar/ui/tests/internal/CustomLaunchConfigTab.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2021 Mat Booth and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.launchbar.ui.tests.internal; + +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +/** + * This is a custom tab that uses a non-GridLayout to test the assumptions made + * by the Launchbar's launch configuration editing dialog. The dialog should not + * generate CCEs if bespoke tabs do not use GridLayout. + * + * See bug 560287 + */ +public class CustomLaunchConfigTab extends AbstractLaunchConfigurationTab { + + @Override + public void createControl(Composite parent) { + parent.setLayout(new RowLayout()); + Label label = new Label(parent, SWT.NONE); + label.setText("This is my custom tab!"); + setControl(label); + } + + @Override + public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { + } + + @Override + public void initializeFrom(ILaunchConfiguration configuration) { + } + + @Override + public void performApply(ILaunchConfigurationWorkingCopy configuration) { + } + + @Override + public String getName() { + return "My Custom Tab"; + } + + @Override + public String getId() { + return "my.custom.tab"; + } +} diff --git a/launchbar/org.eclipse.launchbar.ui.tests/swtbot-test-plugin.properties b/launchbar/org.eclipse.launchbar.ui.tests/swtbot-test-plugin.properties new file mode 100644 index 00000000000..338038b9345 --- /dev/null +++ b/launchbar/org.eclipse.launchbar.ui.tests/swtbot-test-plugin.properties @@ -0,0 +1 @@ +# This file tells the Maven build to use the settings for SWTBot test plugins