Remove SwtBot dependent test classes to fix build for e429
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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<T extends Widget> extends AbstractMatcher<T> {
|
||||
|
||||
@Factory
|
||||
public static <T extends Widget> Matcher<T> inSection(Matcher<?> matcher) {
|
||||
return new InSection<T>(matcher);
|
||||
}
|
||||
|
||||
@Factory
|
||||
public static <T extends Widget> Matcher<T> inSection(String labelText) {
|
||||
return new InSection<T>(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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<Hyperlink> {
|
||||
|
||||
public SWTBotHyperlink(Hyperlink w) throws WidgetNotFoundException {
|
||||
super(w);
|
||||
}
|
||||
|
||||
public SWTBotHyperlink(Hyperlink w, SelfDescribing description) throws WidgetNotFoundException {
|
||||
super(w, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractSWTBot<Hyperlink> click() {
|
||||
return click(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<? extends SWTBotEditor> editors = bot.editors();
|
||||
for (SWTBotEditor editor : editors) {
|
||||
editor.close();
|
||||
}
|
||||
|
||||
StsTestUtil.deleteAllProjects();
|
||||
|
||||
Shell mainWidget = UIThreadRunnable.syncExec(new Result<Shell>() {
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user