mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-03-28 14:56:28 +01:00
Bug 560287 - java.lang.CCE: o.e.swt.layout.GridData cannot be cast
Previously custom launch config tabs could cause a Class Cast Exception
in the Launchbar's edit launch config dialog if they did not use the
GridLayout. Since ed1e058
the launchbar dialog no longer tries to give
the tab control GridLayoutData, avoiding the problem and allowing custom
tabs to use whatever layout they wish.
This change updates the launchbar UI tests to Junit 5 and adds a new
SWTbot test to verify the dialog no longer throws a CCE in this case.
Signed-off-by: Mat Booth <mat.booth@gmail.com>
Change-Id: I05c85cd5f0f5996e46601990b72602383b3fac06
This commit is contained in:
parent
ed1e05876c
commit
6e95a40a57
11 changed files with 178 additions and 81 deletions
|
@ -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
|
||||
|
|
|
@ -3,5 +3,6 @@ output.. = bin/
|
|||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.properties,\
|
||||
about.html
|
||||
about.html,\
|
||||
plugin.xml
|
||||
src.includes = about.html
|
||||
|
|
17
launchbar/org.eclipse.launchbar.ui.tests/plugin.xml
Normal file
17
launchbar/org.eclipse.launchbar.ui.tests/plugin.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.launchConfigurationTabs">
|
||||
<tab
|
||||
class="org.eclipse.launchbar.ui.tests.internal.CustomLaunchConfigTab"
|
||||
group="org.eclipse.pde.ui.launcher.WorkbenchLauncherTabGroup"
|
||||
id="org.eclipse.launchbar.ui.tests.internal.MyCustomTab"
|
||||
name="My Custom Tab">
|
||||
<placement
|
||||
after="org.eclipse.debug.ui.prototypeTab">
|
||||
</placement>
|
||||
</tab>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
|
@ -22,7 +22,7 @@
|
|||
</parent>
|
||||
|
||||
<artifactId>org.eclipse.launchbar.ui.tests</artifactId>
|
||||
<version>1.0.100-SNAPSHOT</version>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-test-plugin</packaging>
|
||||
|
||||
<build>
|
||||
|
@ -31,20 +31,14 @@
|
|||
<groupId>org.eclipse.tycho</groupId>
|
||||
<artifactId>tycho-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- Default configuration, UI tests may have to override these -->
|
||||
<useUIHarness>true</useUIHarness>
|
||||
<useUIThread>false</useUIThread>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<type>p2-installable-unit</type>
|
||||
<artifactId>org.eclipse.pde.feature.group</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<product>org.eclipse.sdk.ide</product>
|
||||
<argLine>${tycho.testArgLine} ${base.ui.test.vmargs}</argLine>
|
||||
<appArgLine>-pluginCustomization ${basedir}/../../disable_intro_in_tests.ini</appArgLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -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<CSelector> {
|
|||
}
|
||||
|
||||
public void clickEdit() {
|
||||
bot().buttonWithId(LaunchBarWidgetIds.EDIT).click(); // $NON-NLS-1$
|
||||
bot().canvasWithId(LaunchBarWidgetIds.EDIT).click();
|
||||
}
|
||||
|
||||
public void select(String text) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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> T getService(Class<T> service) {
|
||||
ServiceReference<T> ref = bundleContext.getServiceReference(service);
|
||||
return ref != null ? bundleContext.getService(ref) : 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 {
|
||||
|
||||
}
|
|
@ -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";
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
# This file tells the Maven build to use the settings for SWTBot test plugins
|
Loading…
Add table
Reference in a new issue