From ac5e2f59e064254cf6736263de09ace551ee0c21 Mon Sep 17 00:00:00 2001 From: aboyko Date: Wed, 23 Aug 2023 18:44:20 -0400 Subject: [PATCH] Remove SwtBot dependent test classes to fix build for e429 --- .../META-INF/MANIFEST.MF | 1 - .../commons/tests/util/swtbot/InSection.java | 68 ------------ .../tests/util/swtbot/SWTBotHyperlink.java | 40 ------- .../commons/tests/util/swtbot/StsBot.java | 94 ---------------- .../tests/util/swtbot/StsBotTestUtil.java | 31 ------ .../tests/util/swtbot/StsUiTestCase.java | 103 ------------------ .../tests/util/swtbot/UiCleanUpTestCase.java | 33 ------ 7 files changed, 370 deletions(-) delete mode 100644 eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/InSection.java delete mode 100644 eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/SWTBotHyperlink.java delete mode 100644 eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/StsBot.java delete mode 100644 eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/StsBotTestUtil.java delete mode 100644 eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/StsUiTestCase.java delete mode 100644 eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/UiCleanUpTestCase.java diff --git a/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/META-INF/MANIFEST.MF b/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/META-INF/MANIFEST.MF index 7ea45a240..ed76b1bde 100644 --- a/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/META-INF/MANIFEST.MF +++ b/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/META-INF/MANIFEST.MF @@ -8,7 +8,6 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.resources, org.eclipse.jdt.core, org.junit;bundle-version="4.8.0", - org.eclipse.swtbot.eclipse.gef.finder, org.eclipse.ui.ide, org.eclipse.ui.views.properties.tabbed, org.eclipse.core.net, diff --git a/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/InSection.java b/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/InSection.java deleted file mode 100644 index cf7063ebd..000000000 --- a/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/InSection.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Pivotal Software, Inc. - * 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 - * https://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal Software, Inc. - initial API and implementation - *******************************************************************************/ -package org.springsource.ide.eclipse.commons.tests.util.swtbot; - -import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic; - -import org.eclipse.swt.widgets.Widget; -import org.eclipse.swtbot.swt.finder.finders.PathGenerator; -import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher; -import org.eclipse.swtbot.swt.finder.utils.SWTUtils; -import org.eclipse.swtbot.swt.finder.utils.TreePath; -import org.eclipse.ui.forms.widgets.Section; -import org.hamcrest.Description; -import org.hamcrest.Factory; -import org.hamcrest.Matcher; - -/** - * @author Leo Dos Santos - */ -public class InSection extends AbstractMatcher { - - @Factory - public static Matcher inSection(Matcher matcher) { - return new InSection(matcher); - } - - @Factory - public static Matcher inSection(String labelText) { - return new InSection(labelText); - } - - private final Matcher matcher; - - InSection(Matcher matcher) { - this.matcher = matcher; - } - - InSection(String labelText) { - matcher = withMnemonic(labelText); - } - - public void describeTo(Description description) { - description.appendText("in section (").appendDescriptionOf(matcher).appendText(")"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - @Override - protected boolean doMatch(Object item) { - Widget previousWidget = SWTUtils.previousWidget((Widget) item); - TreePath path = new PathGenerator().getPath((Widget) item); - int segmentCount = path.getSegmentCount(); - for (int i = 1; i < segmentCount; i++) { - previousWidget = (Widget) path.getSegment(segmentCount - i - 1); - if ((previousWidget instanceof Section) && matcher.matches(previousWidget)) { - return true; - } - } - return false; - } - -} diff --git a/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/SWTBotHyperlink.java b/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/SWTBotHyperlink.java deleted file mode 100644 index a4bacca86..000000000 --- a/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/SWTBotHyperlink.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Pivotal Software, Inc. - * 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 - * https://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal Software, Inc. - initial API and implementation - *******************************************************************************/ -package org.springsource.ide.eclipse.commons.tests.util.swtbot; - -import org.eclipse.swtbot.swt.finder.ReferenceBy; -import org.eclipse.swtbot.swt.finder.SWTBotWidget; -import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; -import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot; -import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl; -import org.eclipse.ui.forms.widgets.Hyperlink; -import org.hamcrest.SelfDescribing; - -/** - * @author Leo Dos Santos - */ -@SWTBotWidget(clasz = Hyperlink.class, preferredName = "hyperlink", referenceBy = { ReferenceBy.MNEMONIC }) -public class SWTBotHyperlink extends AbstractSWTBotControl { - - public SWTBotHyperlink(Hyperlink w) throws WidgetNotFoundException { - super(w); - } - - public SWTBotHyperlink(Hyperlink w, SelfDescribing description) throws WidgetNotFoundException { - super(w, description); - } - - @Override - public AbstractSWTBot click() { - return click(true); - } - -} diff --git a/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/StsBot.java b/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/StsBot.java deleted file mode 100644 index 8577a767c..000000000 --- a/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/StsBot.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Pivotal Software, Inc. - * 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 - * https://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal Software, Inc. - initial API and implementation - *******************************************************************************/ -package org.springsource.ide.eclipse.commons.tests.util.swtbot; - -import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf; -import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType; -import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic; -import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withStyle; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; -import org.eclipse.ui.forms.widgets.Hyperlink; -import org.hamcrest.Matcher; - -/** - * @author Leo Dos Santos - * @author Terry Denney - */ -public class StsBot extends SWTWorkbenchBot { - - public SWTBotButton flatButton(String mnemonicText) { - return flatButton(mnemonicText, 0); - } - - @SuppressWarnings("unchecked") - public SWTBotButton flatButton(String mnemonicText, int index) { - Matcher matcher = allOf(widgetOfType(Button.class), withMnemonic(mnemonicText), withStyle(SWT.FLAT, "SWT.FLAT")); - return new SWTBotButton((Button) widget(matcher, index), matcher); - } - - public SWTBotButton flatButtonInSection(String mnemonicText, String inSection) { - return flatButtonInSection(mnemonicText, inSection, 0); - } - - @SuppressWarnings("unchecked") - public SWTBotButton flatButtonInSection(String mnemonicText, String inSection, int index) { - Matcher matcher = allOf(widgetOfType(Button.class), withMnemonic(mnemonicText), InSection.inSection(inSection), - withStyle(SWT.FLAT, "SWT.FLAT")); - return new SWTBotButton((Button) widget(matcher, index), matcher); - } - - public SWTBotHyperlink hyperlink(String mnemonicText) { - return hyperlink(mnemonicText, 0); - } - - @SuppressWarnings("unchecked") - public SWTBotHyperlink hyperlink(String mnemonicText, int index) { - Matcher matcher = allOf(widgetOfType(Hyperlink.class), withMnemonic(mnemonicText)); - return new SWTBotHyperlink((Hyperlink) widget(matcher, index), matcher); - } - - @SuppressWarnings("unchecked") - public SWTBotRadio radioInSection(String mnemonicText, String inSection) { - Matcher matcher = allOf(widgetOfType(Button.class), withMnemonic(mnemonicText), InSection.inSection(inSection), - withStyle(SWT.RADIO, "SWT.RADIO")); - return new SWTBotRadio((Button) widget(matcher, 0), matcher); - } - - public SWTBotTable tableInSection(String inSection) { - return tableInSection(inSection, 0); - } - - @SuppressWarnings("unchecked") - public SWTBotTable tableInSection(String inSection, int index) { - Matcher matcher = allOf(widgetOfType(Table.class), InSection.inSection(inSection)); - return new SWTBotTable((Table) widget(matcher, index), matcher); - } - - public SWTBotTree treeInSection(String inSection) { - return treeInSection(inSection, 0); - } - - @SuppressWarnings("unchecked") - public SWTBotTree treeInSection(String inSection, int index) { - Matcher matcher = allOf(widgetOfType(Tree.class), InSection.inSection(inSection)); - return new SWTBotTree((Tree) widget(matcher, index), matcher); - } - -} diff --git a/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/StsBotTestUtil.java b/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/StsBotTestUtil.java deleted file mode 100644 index b57a80586..000000000 --- a/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/StsBotTestUtil.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Pivotal Software, Inc. - * 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 - * https://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal Software, Inc. - initial API and implementation - *******************************************************************************/ -package org.springsource.ide.eclipse.commons.tests.util.swtbot; - -import org.eclipse.swtbot.swt.finder.SWTBot; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; - -/** - * @author Terry Denney - */ -public class StsBotTestUtil { - - public static void showView(String category, String view, SWTBot bot) { - bot.menu("Window").menu("Show View").menu("Other...").click(); - - SWTBotShell shell = bot.shell("Show View"); - shell.activate(); - - bot.tree().expandNode(category).select(view); - bot.button("OK").click(); - } - -} diff --git a/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/StsUiTestCase.java b/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/StsUiTestCase.java deleted file mode 100644 index 850a7f829..000000000 --- a/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/StsUiTestCase.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Pivotal Software, Inc. - * 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 - * https://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal Software, Inc. - initial API and implementation - *******************************************************************************/ -package org.springsource.ide.eclipse.commons.tests.util.swtbot; - -import java.util.List; - -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor; -import org.eclipse.swtbot.swt.finder.SWTBotTestCase; -import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; -import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; -import org.eclipse.swtbot.swt.finder.results.Result; -import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.eclipse.ui.PlatformUI; -import org.junit.After; -import org.junit.Before; -import org.springsource.ide.eclipse.commons.tests.util.StsTestUtil; - - -/** - * @author Steffen Pingel - * @author Terry Denney - */ -public abstract class StsUiTestCase extends SWTBotTestCase { - - protected StsBot bot; - - private final String defaultKbLayout = SWTBotPreferences.KEYBOARD_LAYOUT; - - @After - public void after() throws Exception { - cleanUp(); - } - - @Before - public void before() throws Exception { - setUp(); - } - - protected void cleanUp() throws Exception { - List editors = bot.editors(); - for (SWTBotEditor editor : editors) { - editor.close(); - } - - StsTestUtil.deleteAllProjects(); - - Shell mainWidget = UIThreadRunnable.syncExec(new Result() { - public Shell run() { - return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - } - }); - SWTBotShell[] shells = bot.shells(); - SWTBotShell mainShell = null; - for (SWTBotShell shell : shells) { - if (shell.widget != mainWidget) { - shell.close(); - } - else { - mainShell = shell; - } - } - if (mainShell != null) { - mainShell.activate(); - } - } - - @Override - public void setUp() throws Exception { - try { - SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; - bot = new StsBot(); - try { - bot.viewByTitle("Welcome").close(); - } - catch (WidgetNotFoundException e) { - // ignore - } - - // run in setUp() to enable super class to capture screenshot in - // case of a failure - cleanUp(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - protected void tearDown() throws Exception { - SWTBotPreferences.KEYBOARD_LAYOUT = defaultKbLayout; - super.tearDown(); - } - -} diff --git a/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/UiCleanUpTestCase.java b/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/UiCleanUpTestCase.java deleted file mode 100644 index 9c6aa3393..000000000 --- a/eclipse-language-servers/org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/swtbot/UiCleanUpTestCase.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Pivotal Software, Inc. - * 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 - * https://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal Software, Inc. - initial API and implementation - *******************************************************************************/ -package org.springsource.ide.eclipse.commons.tests.util.swtbot; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Empty test case that runs super method for setup and tear down for general - * cleanup. - * @author Steffen Pingel - */ -public class UiCleanUpTestCase extends StsUiTestCase { - - public static Test suite() { - TestSuite suite = new TestSuite(UiCleanUpTestCase.class.getName()); - suite.addTestSuite(UiCleanUpTestCase.class); - return suite; - } - - public void testVoid() { - // do nothing - } - -}