diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/Abstract4diacUITests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/Abstract4diacUITests.java index 8d1f7bbe04..b5feb094ee 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/Abstract4diacUITests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/Abstract4diacUITests.java @@ -17,33 +17,23 @@ package org.eclipse.fordiac.ide.test.ui; import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellCloses; -import static org.eclipse.swtbot.swt.finder.waits.Conditions.treeItemHasNode; -import static org.junit.Assert.assertNull; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.List; -import java.util.Map; import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.fordiac.ide.application.editparts.FBEditPart; -import org.eclipse.fordiac.ide.application.editparts.SubAppForFBNetworkEditPart; +import org.eclipse.fordiac.ide.test.ui.helpers.PropertySheetHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotSystemExplorer; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWT4diacGefBot; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefViewer; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacNatTable; -import org.eclipse.gef.ConnectionEditPart; -import org.eclipse.gef.EditPart; import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.GraphicalViewer; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Tree; import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; @@ -55,11 +45,8 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotCTabItem; import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; import org.junit.AfterClass; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; @@ -81,7 +68,7 @@ public class Abstract4diacUITests { protected static void beforeAll() { bot = new SWT4diacGefBot(); bot.viewByTitle("Welcome").close(); //$NON-NLS-1$ - SWTBotPreferences.TIMEOUT = 30000; + SWTBotPreferences.TIMEOUT = 8000; SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; //$NON-NLS-1$ createProject(); } @@ -106,265 +93,6 @@ protected static void createProject() { bot.waitUntil(shellCloses(shell)); } - /** - * Drags and drops a FB onto the canvas with given name and position. - * - * @param fbName The name of the Function Block. - * @param point The Position of the FB on the canvas. - */ - protected static void dragAndDropEventsFB(final String fbName, final Point point) { - final SWTBotTreeItem typeLibraryNode = expandTypeLibraryTreeItemInSystemExplorer(); - bot.waitUntil(treeItemHasNode(typeLibraryNode, UITestNamesHelper.EVENTS_NODE)); - final SWTBotTreeItem eventsNode = typeLibraryNode.getNode(UITestNamesHelper.EVENTS_NODE); - eventsNode.select(); - eventsNode.expand(); - bot.waitUntil(treeItemHasNode(eventsNode, fbName)); - final SWTBotTreeItem eCycleNode = eventsNode.getNode(fbName); - eCycleNode.select(); - eCycleNode.click(); - - // select application editor - final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); - final SWTBot4diacGefViewer viewer = (SWTBot4diacGefViewer) editor.getSWTBotGefViewer(); - final SWTBotGefFigureCanvas canvas = viewer.getCanvas(); - - assertNotNull(canvas); - eCycleNode.dragAndDrop(canvas, point); - } - - /** - * Checks if given element is visible in the Application of the System in the - * SystemExplorer Tree. - * - * @param element The name of the element (function block or SubApp) searched - * for in the Application of the System in the SystemExplorer - * tree. - */ - protected static boolean isElementInApplicationOfSystemInSystemExplorer(final String element) { - final SWTBotTreeItem appNode = expandApplicationTreeItemInSystemExplorer(); - bot.waitUntil(treeItemHasNode(appNode, element)); - final SWTBotTreeItem elementNode = appNode.getNode(element); - assertNotNull(elementNode); - return elementNode.isVisible(); - } - - /** - * Checks if given Function Block is visible in the SubApp node of the - * Application the System in the SystemExplorer Tree. - * - * @param fbName The name of the function block searched for in the SubApp node - * of the Application in the System in the SystemExplorer tree. - */ - protected static boolean isFBInSubAppOfSystemInSystemExplorer(final String fbName) { - final SWTBotTreeItem subAppNode = expandSubAppTreeItemInSystemExplorer(); - final SWTBotTreeItem fbNode = subAppNode.getNode(fbName); - assertNotNull(fbNode); - return fbNode.isVisible(); - } - - protected static boolean isSubAppNodeInSystemExplorerEmpty() { - final SWTBotTreeItem subAppNode = expandSubAppTreeItemInSystemExplorer(); - final List subAppChildren = subAppNode.getNodes(); - return subAppChildren.isEmpty(); - } - - protected static void createSubappWithDragRectangle(final int fromXPosition, final int fromYPosition, - final int toXPosition, final int toYPosition) { - final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); - editor.drag(fromXPosition, fromYPosition, toXPosition, toYPosition); - bot.menu(UITestNamesHelper.SOURCE).menu(UITestNamesHelper.NEW_SUBAPPLICATION).click(); - - } - - /** - * Selects a FunctionBlock with the given Name in the editor. - * - * The function block is searched for with the given name in the editor. - * However, as this only selects the name, the parent is retrieved and selected. - * Only then is the searched function block selected as a whole. - * - * @param editor - * @param name - */ - protected static SWTBot4diacGefEditor selectFBWithFBNameInEditor(final SWTBot4diacGefEditor editor, - final String name) { - assertNotNull(editor); - assertNotNull(editor.getEditPart(name)); - editor.click(name); - final SWTBotGefEditPart parent = editor.getEditPart(name).parent(); - assertNotNull(parent); - editor.click(parent); - return editor; - } - - /** - * Deletes a FB from the editing area. - * - * @param editor The SWTBot4diacGefEditor from which a FB with given - * instance name should be deleted. - * @param FbInstanceName The instance name of the FB - */ - protected static void deleteFB(final SWTBot4diacGefEditor editor, final String FbInstanceName) { - editor.setFocus(); - final SWTBotGefEditPart fb = editor.getEditPart(FbInstanceName).parent(); - fb.select().click(); - bot.menu(UITestNamesHelper.EDIT).menu(UITestNamesHelper.DELETE).click(); - } - - /** - * Creates a connection between two pins. - * - * The method creates a connection between the two given pins, the order of the - * pins is not important and returns a SWTBot4diacGefViewer. Whether a - * connection could actually be created is not checked here. - * - * @param pin1 One of the two pins between a connection is (tried to) create. - * @param pin2 One of the two pins between a connection is (tried to) create. - * @return SWTBot4diacGefViewer - */ - protected static SWTBot4diacGefViewer createConnection(final String pin1, final String pin2) { - final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); - assertNotNull(editor); - final SWTBot4diacGefViewer viewer = (SWTBot4diacGefViewer) editor.getSWTBotGefViewer(); - assertNotNull(viewer); - // select input pin - editor.click(pin1); - final SWTBotGefEditPart ei = editor.getEditPart(pin1); - assertNotNull(ei); - final IFigure figure = ((GraphicalEditPart) ei.part()).getFigure(); - assertNotNull(figure); - final Rectangle inputPinBounds1 = figure.getBounds().getCopy(); - assertNotNull(inputPinBounds1); - figure.translateToAbsolute(inputPinBounds1); - // select output pin - editor.click(pin2); - final SWTBotGefEditPart eo = editor.getEditPart(pin2); - assertNotNull(eo); - final Rectangle inputPinBounds2 = ((GraphicalEditPart) eo.part()).getFigure().getBounds().getCopy(); - assertNotNull(inputPinBounds2); - figure.translateToAbsolute(inputPinBounds2); - viewer.drag(pin2, inputPinBounds1.getCenter().x, inputPinBounds1.getCenter().y); - checkIfConnectionCanBeFound(pin1, pin2); - return viewer; - } - - protected static boolean checkIfConnectionCanBeFound(final String srcPinName, final String dstPinName) { - return findConnection(srcPinName, dstPinName) != null; - } - - protected static ConnectionEditPart findConnection(final String srcPinName, final String dstPinName) { - final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); - final SWTBot4diacGefViewer viewer = (SWTBot4diacGefViewer) editor.getSWTBotGefViewer(); - final GraphicalViewer graphicalViewer = viewer.getGraphicalViewer(); - - return Display.getDefault().syncCall(() -> { - graphicalViewer.flush(); - final Map editPartRegistry = graphicalViewer.getEditPartRegistry(); - for (final Object obj : editPartRegistry.values()) { - if (obj instanceof final ConnectionEditPart cEP) { - // search for connection between the 2 pins - final EditPart source = cEP.getSource(); - final EditPart target = cEP.getTarget(); - - final IFigure srcFigure = ((GraphicalEditPart) source).getFigure(); - final Label srcLabel = (Label) srcFigure; - final String srcText = srcLabel.getText(); - - final IFigure dstFigure = ((GraphicalEditPart) target).getFigure(); - final Label dstLabel = (Label) dstFigure; - final String dstText = dstLabel.getText(); - - if (srcPinName.equals(srcText) && dstPinName.equals(dstText)) { - return cEP; - } - - } - } - return null; - }); - } - - protected static Rectangle getAbsolutePosition(final SWTBotGefEditor editor, final String fb) { - final SWTBotGefEditPart parent = editor.getEditPart(fb).parent(); - assertNotNull(parent); - final IFigure figurePos = ((GraphicalEditPart) parent.part()).getFigure(); - assertNotNull(figurePos); - final Rectangle fbBounds = figurePos.getBounds().getCopy(); - assertNotNull(fbBounds); - figurePos.translateToAbsolute(fbBounds); - return fbBounds; - } - - /** - * Checks if FB is selected by searching selectedEditParts list and returns the - * corresponding boolean value. - * - * @param selectedEditParts The List of selected EditParts. - * @param fbName The FB that is searched for. - * @return true if fbName is in the List, otherwise false. - */ - protected static boolean isFbSelected(final List selectedEditParts, final String fbName) { - return selectedEditParts.stream().filter(p -> p.part() instanceof FBEditPart).map(p -> (FBEditPart) p.part()) - .anyMatch(fb -> fb.getModel().getName().equals(fbName)); - } - - /** - * Checks if Subapplication is selected by searching selectedEditParts list and - * returns the corresponding boolean value. - * - * @param selectedEditParts The List of selected EditParts. - * @param subAppName The Subapplication that is searched for. - * @return true if Subapplication is in the List, otherwise false. - */ - protected static boolean isSubappSelected(final List selectedEditParts, - final String subAppName) { - return selectedEditParts.stream().filter(p -> p.part() instanceof SubAppForFBNetworkEditPart) - .map(p -> (SubAppForFBNetworkEditPart) p.part()) - .anyMatch(fb -> subAppName.equals(fb.getModel().getName())); - } - - /** - * Checks if given FB instance name can be found on the editing area. - * - * @param editor The SWTBot4diacGefEditor in which the FB instance name is - * searched - * @param fbName The String of the FB instance name searched for - * @return true if FB is onto editing area, false if not - */ - protected static boolean isFBNamePresendOnEditingArea(final SWTBot4diacGefEditor editor, final String fbName) { - final List editParts = editor.editParts(new BaseMatcher() { - @Override - public boolean matches(final Object item) { - return item instanceof FBEditPart; - } - - @Override - public void describeTo(final Description description) { - // method must be implemented but empty since not needed - } - }); - assertFalse(editParts.isEmpty()); - return editParts.stream().filter(p -> p.part() instanceof FBEditPart).map(p -> (FBEditPart) p.part()) - .anyMatch(fb -> fb.getModel().getName().equals(fbName)); - } - - /** - * Returns the bounds of the searched function block - * - * @param editor - * @param fBname - * @return The rectangle with the bounds of the function block searched for - */ - protected static Rectangle getBoundsOfFB(final SWTBot4diacGefEditor editor, final String fBname) { - editor.getEditPart(fBname); - editor.click(fBname); - final SWTBotGefEditPart parent = editor.getEditPart(fBname).parent(); - final IFigure figure = ((GraphicalEditPart) parent.part()).getFigure(); - final Rectangle fbBounds = figure.getBounds().getCopy(); - figure.translateToAbsolute(fbBounds); - return fbBounds; - } - /** * Select a given FB on the editing area and double click it to access the * CompositeInstanceViewer. After that the SWTBotGefEditor will be returned. @@ -386,170 +114,12 @@ protected static SWTBotGefEditor goToCompositeInstanceViewer(final String fb) { return editor; } - /** - * Creates a New Type with given name. - * - * @param parentName Name of the parent project. - * @param typeName Name of the new type. - * @param typeLabel Name of the Type Label. - */ - protected static void createFBType(final String parentName, final String typeName, final String typeLabel) { - bot.menu(UITestNamesHelper.FILE).menu(UITestNamesHelper.NEW).menu(UITestNamesHelper.TYPE_PROJECT).click(); - final SWTBotShell shell = bot.shell(UITestNamesHelper.NEW_TYPE); - shell.activate(); - bot.textWithLabel(UITestNamesHelper.TYPE_NAME_LABEL).setText(typeName); - bot.textWithLabel(UITestNamesHelper.PARENT_FOLDER_NAME_LABEL).setText(parentName); - assertEquals(bot.textWithLabel(UITestNamesHelper.TYPE_NAME_LABEL).getText(), typeName); - bot.tableWithLabel(UITestNamesHelper.SELECT_TYPE_LABEL).getTableItem(typeLabel).select(); - bot.button(UITestNamesHelper.FINISH).click(); - bot.waitUntil(shellCloses(shell)); - } - - /** - * Deletes FB Type with give name. - * - * @param typeName Name of the new type. - */ - protected static void deleteFBType(final String typeName) { - final SWTBotView systemExplorerView = bot.viewById(UITestNamesHelper.SYSTEM_EXPLORER_ID); - systemExplorerView.show(); - final Composite systemExplorerComposite = (Composite) systemExplorerView.getWidget(); - - final Tree swtTree = bot.widget(WidgetMatcherFactory.widgetOfType(Tree.class), systemExplorerComposite); - final SWTBotTree tree = new SWTBotTree(swtTree); - final SWTBotTreeItem parentItem = tree.getTreeItem(UITestNamesHelper.PROJECT_NAME); - parentItem.expand(); - SWTBotTreeItem projectItem = null; - for (final SWTBotTreeItem item : parentItem.getItems()) { - if (item.getText().contains(typeName)) { - projectItem = item; - break; - } - } - projectItem.select(); - bot.menu(UITestNamesHelper.EDIT).menu(UITestNamesHelper.DELETE).click(); - - // the project deletion confirmation dialog - final SWTBotShell shell = bot.shell(UITestNamesHelper.DELETE_RESOURCES); - shell.activate(); - bot.button(UITestNamesHelper.OK).click(); - bot.waitUntil(shellCloses(shell)); - final List nodeList = parentItem.getNodes(); - assertFalse(nodeList.contains(typeName)); - } - - /** - * Open FB Type in editor from explorer. - * - * @param parentName Name of the parent Project. - * @param typeName Name of the new type. - */ - protected static void openFBTypeInEditor(final String parentName, final String typeName) { - final SWTBotView systemExplorerView = bot.viewByTitle(UITestNamesHelper.SYSTEM_EXPLORER_LABEL); - systemExplorerView.show(); - final Composite systemExplorerComposite = (Composite) systemExplorerView.getWidget(); - final Tree swtTree = bot.widget(WidgetMatcherFactory.widgetOfType(Tree.class), systemExplorerComposite); - final SWTBotTree tree = new SWTBotTree(swtTree); - final SWTBotTreeItem parentItem = tree.getTreeItem(parentName); - parentItem.expand(); - SWTBotTreeItem projectItem = null; - for (final SWTBotTreeItem item : parentItem.getItems()) { - if (item.getText().contains(typeName)) { - projectItem = item; - break; - } - } - assertTrue(projectItem.getText().contains(typeName)); - } - - /** - * Deletes the given pin on the FB opened the provided editor. - * - * @param editor Selected Gef Editor - * @param pinName Name of pin. - */ - protected static void deletePin(final SWTBot4diacGefEditor editor, final String pinName) { - final SWTBotGefEditPart pin = editor.getEditPart(pinName); - assertNotNull(pin); - pin.click(); - editor.clickContextMenu(UITestNamesHelper.DELETE); - assertNull(editor.getEditPart(pinName)); - } - - /** - * Creates connection within FB Type from Property Sheet - * - * @param pin1 Name of pin1. - * @param pin2 Name of pin2. - * @param editor Selected Gef Editor - */ - protected static void createConnectionWithinFBTypeWithPropertySheet(final String pin1, final String pin2, - final SWTBot4diacGefEditor editor) { - - final SWTBotGefEditPart port1 = editor.getEditPart(pin1); - port1.click(); - - final SWTBotGefEditPart port2 = editor.getEditPart(pin2); - port2.click(); - - SWTBot propertiesBot = bot.viewByTitle(UITestNamesHelper.PROPERTIES_TITLE).bot(); - bot.viewByTitle(UITestNamesHelper.PROPERTIES_TITLE).setFocus(); - - if (PropertySheetHelper.selectPropertyTabItem(UITestNamesHelper.EVENT, propertiesBot)) { - propertiesBot = selectTabFromInterfaceProperties(UITestNamesHelper.EVENT); - } else { - propertiesBot = selectTabFromInterfaceProperties(UITestNamesHelper.DATA); - } - - // Find the group with the label "With" - final SWTBotTable table = propertiesBot.tableInGroup(UITestNamesHelper.WITH); - - table.select(pin1); - table.getTableItem(pin1).toggleCheck(); - assertTrue(table.getTableItem(pin1).isChecked()); - checkIfConnectionCanBeFound(pin1, pin2); - } - - /** - * Remove connection within FB Type from Property Sheet - * - * @param pin1 Name of pin1. - * @param pin2 Name of pin2. - * @param editor Selected Gef Editor - */ - protected static void removeConnectionWithinFBTypeWithPropertySheet(final String pin1, final String pin2, - final SWTBot4diacGefEditor editor) { - - final SWTBotGefEditPart port1 = editor.getEditPart(pin1); - editor.click(port1); - - final SWTBotGefEditPart port2 = editor.getEditPart(pin2); - port2.click(); - - SWTBot propertiesBot = bot.viewByTitle(UITestNamesHelper.PROPERTIES_TITLE).bot(); - bot.viewByTitle(UITestNamesHelper.PROPERTIES_TITLE).setFocus(); - - if (PropertySheetHelper.selectPropertyTabItem(UITestNamesHelper.EVENT, propertiesBot)) { - propertiesBot = selectTabFromInterfaceProperties(UITestNamesHelper.EVENT); - } else { - propertiesBot = selectTabFromInterfaceProperties(UITestNamesHelper.DATA); - } - - // Find the group with the label "With" - final SWTBotTable table = propertiesBot.tableInGroup(UITestNamesHelper.WITH); - - table.select(pin1); - table.getTableItem(pin1).toggleCheck(); - assertFalse(table.getTableItem(pin1).isChecked()); - checkIfConnectionCanBeFound(pin1, pin2); - } - /** * Select tab from Interface's Properties * * @param tabName Name of Tab on Property Sheet under Interface */ - protected static SWTBot selectTabFromInterfaceProperties(final String tabName) { + public static SWTBot selectTabFromInterfaceProperties(final String tabName) { // Interface tab final SWTBotCTabItem interfaceTab = bot.cTabItem(UITestNamesHelper.INTERFACE); interfaceTab.activate(); @@ -730,7 +300,8 @@ protected static void deleteProject() { @SuppressWarnings("static-method") @AfterEach protected void cleanEditorArea() { - final SWTBotTreeItem appNode = expandApplicationTreeItemInSystemExplorer(); + final SWTBotSystemExplorer sysExBot = new SWTBotSystemExplorer(bot); + final SWTBotTreeItem appNode = sysExBot.expandApplicationTreeItemInSystemExplorer(); appNode.contextMenu("Open").click(); final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); @@ -754,84 +325,4 @@ protected static void afterClass() { bot.resetWorkbench(); } - /** - * Expands the 4diac IDE Project node (SWTBotTreeItem) in the System Explorer - * - * @author Andrea Zoitl - * @return treeProjectItem the expanded Project node - */ - private static SWTBotTreeItem expandProjectTreeItemInSystemExplorer() { - final SWTBotView systemExplorerView = bot.viewById(UITestNamesHelper.SYSTEM_EXPLORER_ID); - systemExplorerView.show(); - final Composite systemExplorerComposite = (Composite) systemExplorerView.getWidget(); - final Tree swtTree = bot.widget(WidgetMatcherFactory.widgetOfType(Tree.class), systemExplorerComposite); - final SWTBotTree tree = new SWTBotTree(swtTree); - assertNotNull(tree); - final SWTBotTreeItem treeProjectItem = tree.getTreeItem(UITestNamesHelper.PROJECT_NAME); - treeProjectItem.select(); - treeProjectItem.expand(); - return treeProjectItem; - } - - /** - * Expands the System node (SWTBotTreeItem) in the System Explorer - * - * @author Andrea Zoitl - * @return systemNode the expanded System node - */ - private static SWTBotTreeItem expandSystemTreeItemInSystemExplorer() { - final SWTBotTreeItem treeProjectItem = expandProjectTreeItemInSystemExplorer(); - bot.waitUntil(treeItemHasNode(treeProjectItem, UITestNamesHelper.PROJECT_NAME_TREE_ITEM)); - final SWTBotTreeItem systemNode = treeProjectItem.getNode(UITestNamesHelper.PROJECT_NAME_TREE_ITEM); - systemNode.select(); - systemNode.expand(); - return systemNode; - } - - /** - * Expands the Type Library node (SWTBotTreeItem) in the System Explorer - * - * @author Andrea Zoitl - * @return typeLibraryNode the expanded Type Library node - */ - private static SWTBotTreeItem expandTypeLibraryTreeItemInSystemExplorer() { - final SWTBotTreeItem treeProjectItem = expandProjectTreeItemInSystemExplorer(); - bot.waitUntil(treeItemHasNode(treeProjectItem, UITestNamesHelper.TYPE_LIBRARY_NODE)); - final SWTBotTreeItem typeLibraryNode = treeProjectItem.getNode(UITestNamesHelper.TYPE_LIBRARY_NODE); - typeLibraryNode.select(); - typeLibraryNode.expand(); - return typeLibraryNode; - } - - /** - * Expands the Application node (SWTBotTreeItem) in the System Explorer - * - * @author Andrea Zoitl - * @return appNode the expanded Application node - */ - private static SWTBotTreeItem expandApplicationTreeItemInSystemExplorer() { - final SWTBotTreeItem systemNode = expandSystemTreeItemInSystemExplorer(); - bot.waitUntil(treeItemHasNode(systemNode, UITestNamesHelper.PROJECT_NAME_APP)); - final SWTBotTreeItem appNode = systemNode.getNode(UITestNamesHelper.PROJECT_NAME_APP); - assertNotNull(appNode); - appNode.select(); - appNode.expand(); - return appNode; - } - - /** - * Expands the Subapplication node (SWTBotTreeItem) of the 1. level of an - * Application in the System Explorer - * - * @author Andrea Zoitl - * @return appNode the expanded Application node - */ - private static SWTBotTreeItem expandSubAppTreeItemInSystemExplorer() { - final SWTBotTreeItem appNode = expandApplicationTreeItemInSystemExplorer(); - final SWTBotTreeItem subAppNode = appNode.getNode(UITestNamesHelper.SUBAPP); - assertNotNull(subAppNode); - subAppNode.select(); - subAppNode.expand(); - return subAppNode; - } } diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/FirstTry.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/FirstTry.java deleted file mode 100644 index 0d269f01f0..0000000000 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/FirstTry.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2023 Andrea Zoitl - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Andrea Zoitl - initial API and implementation and/or initial documentation - *******************************************************************************/ -package org.eclipse.fordiac.ide.test.ui; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; - -public class FirstTry { - - private final SWTWorkbenchBot bot = new SWTWorkbenchBot(); - - @Test - public void test() { - assertTrue(true); - } - - @Test - public void executeExit() { - final SWTBotMenu fileMenu = bot.menu("File"); //$NON-NLS-1$ - assertNotNull(fileMenu); - } - - @Test - public void canCreateANewJavaProject() throws Exception { - bot.menu("File").menu("New").menu("4diac IDE Project...").click(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - bot.textWithLabel("Project name:").setText("UiTestProject"); //$NON-NLS-1$ //$NON-NLS-2$ - bot.button("Finish").click(); //$NON-NLS-1$ - } - - @AfterEach - public void sleep() { - bot.sleep(2000); - } -} diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/AttributesTabTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/AttributesTabTests.java index daae97b6ad..42a92f1caf 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/AttributesTabTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/AttributesTabTests.java @@ -14,7 +14,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; -import org.eclipse.fordiac.ide.test.ui.PropertySheetHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.PropertySheetHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFBType; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacNatTable; import org.eclipse.nebula.widgets.nattable.NatTable; @@ -38,9 +39,10 @@ public void operationsInitialization() { TESTVAR1 = UITestNamesHelper.ATTRIBUTE1; TESTVAR2 = UITestNamesHelper.ATTRIBUTE2; TESTVAR3 = UITestNamesHelper.ATTRIBUTE3; - createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, + final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); + fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, UITestNamesHelper.TEMPLATEBASIC); - openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); + fbTypeBot.openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); final SWTBot propertiesBot = selectTabFromInterfaceProperties(UITestNamesHelper.ATTRIBUTES); assertNotNull(propertiesBot); bot.viewByTitle(UITestNamesHelper.PROPERTIES_TITLE).setFocus(); diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/BasicFBTOperationTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/BasicFBTOperationTests.java index 09c82baf10..ab39c94fb2 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/BasicFBTOperationTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/BasicFBTOperationTests.java @@ -20,6 +20,8 @@ import org.eclipse.fordiac.ide.test.ui.Abstract4diacUITests; import org.eclipse.fordiac.ide.test.ui.helpers.PinNamesHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotConnection; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFBType; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; @@ -46,8 +48,10 @@ public class BasicFBTOperationTests extends Abstract4diacUITests { @SuppressWarnings("static-method") @BeforeEach public void operationsInitialization() { - createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, UITestNamesHelper.ADAPTER); - openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); + final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); + fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, + UITestNamesHelper.ADAPTER); + fbTypeBot.openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); } /** @@ -61,7 +65,7 @@ public void operationsInitialization() { @SuppressWarnings("static-method") @AfterEach public void resetEnvironment() { - deleteFBType(UITestNamesHelper.FBT_TEST_PROJECT2); + new SWTBotFBType(bot).deleteFBType(UITestNamesHelper.FBT_TEST_PROJECT2); } /** @@ -91,7 +95,7 @@ public void createNewEventInput() { public void createNewEventOutput() { final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.FBT_TEST_PROJECT2); editor.clickContextMenu(UITestNamesHelper.CREATE_OUTPUT_EVENT); - assertNotNull(editor.getEditPart(PinNamesHelper.EI1)); + assertNotNull(editor.getEditPart(PinNamesHelper.EO1)); } /** @@ -196,7 +200,7 @@ public void changeDataPinComment() { * select the property sheet's tabs properly, then click on checkbox to create * with connection. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void addConnection() { final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.FBT_TEST_PROJECT2); @@ -211,7 +215,8 @@ public void addConnection() { final SWTBotGefEditPart outputPin = editor.getEditPart(PinNamesHelper.DI1); outputPin.click(); - createConnectionWithinFBTypeWithPropertySheet(PinNamesHelper.DI1, PinNamesHelper.EI1, editor); + final SWTBotConnection connect = new SWTBotConnection(bot); + connect.createConnectionWithinFBTypeWithPropertySheet(PinNamesHelper.DI1, PinNamesHelper.EI1, editor); } /** @@ -222,7 +227,7 @@ public void addConnection() { * select the property sheet's tabs properly, then click on checkbox to remove * with connection. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void removeConnection() { final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.FBT_TEST_PROJECT2); @@ -237,9 +242,9 @@ public void removeConnection() { final SWTBotGefEditPart outputPin = editor.getEditPart(PinNamesHelper.DI1); outputPin.click(); - createConnectionWithinFBTypeWithPropertySheet(PinNamesHelper.DI1, PinNamesHelper.EI1, editor); - - removeConnectionWithinFBTypeWithPropertySheet(PinNamesHelper.DI1, PinNamesHelper.EI1, editor); + final SWTBotConnection connect = new SWTBotConnection(bot); + connect.createConnectionWithinFBTypeWithPropertySheet(PinNamesHelper.DI1, PinNamesHelper.EI1, editor); + connect.removeConnectionWithinFBTypeWithPropertySheet(PinNamesHelper.DI1, PinNamesHelper.EI1, editor); } /** diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/ConstantsTabTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/ConstantsTabTests.java index 29cc6024df..a28da0ebdb 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/ConstantsTabTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/ConstantsTabTests.java @@ -14,7 +14,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; -import org.eclipse.fordiac.ide.test.ui.PropertySheetHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.PropertySheetHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFBType; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacNatTable; import org.eclipse.nebula.widgets.nattable.NatTable; @@ -30,9 +31,10 @@ public void operationsInitialization() { TESTVAR1 = UITestNamesHelper.INTERNALCONSTVAR1; TESTVAR2 = UITestNamesHelper.INTERNALCONSTVAR2; TESTVAR3 = UITestNamesHelper.INTERNALCONSTVAR3; - createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, + final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); + fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, UITestNamesHelper.TEMPLATEBASIC); - openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); + fbTypeBot.openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); final SWTBot propertiesBot = selectTabFromInterfaceProperties(UITestNamesHelper.CONSTANTS); assertNotNull(propertiesBot); bot.viewByTitle(UITestNamesHelper.PROPERTIES_TITLE).setFocus(); diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/CreateFBTTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/CreateFBTTests.java index eac9bcb3c6..12fc6ff0ea 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/CreateFBTTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/CreateFBTTests.java @@ -21,6 +21,7 @@ import java.util.List; import org.eclipse.fordiac.ide.test.ui.Abstract4diacUITests; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFBType; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Tree; @@ -87,7 +88,7 @@ public void createNewFBTypeWithoutPackage() { parentItem.expand(); final SWTBotTreeItem projectItem = parentItem.getNode(UITestNamesHelper.FBT_TEST_PROJECT1); assertEquals(projectItem.getText(), UITestNamesHelper.FBT_TEST_PROJECT1); - deleteFBType(UITestNamesHelper.FBT_TEST_PROJECT1); + new SWTBotFBType(bot).deleteFBType(UITestNamesHelper.FBT_TEST_PROJECT1); } /** @@ -149,7 +150,7 @@ public void createNewFBTypeWithPackage() { parentItem.expand(); final SWTBotTreeItem projectItem = parentItem.getNode(UITestNamesHelper.FBT_TEST_PROJECT2); assertEquals(projectItem.getText(), UITestNamesHelper.FBT_TEST_PROJECT2); - deleteFBType(UITestNamesHelper.FBT_TEST_PROJECT2); + new SWTBotFBType(bot).deleteFBType(UITestNamesHelper.FBT_TEST_PROJECT2); } /** @@ -202,7 +203,8 @@ public void tryToCreateFBTypeWithForbiddenName() { @SuppressWarnings("static-method") @Test public void tryToCreateANewFBTypeWithExistingName() { - createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT3, UITestNamesHelper.ADAPTER); + new SWTBotFBType(bot).createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT3, + UITestNamesHelper.ADAPTER); bot.menu(UITestNamesHelper.FILE).menu(UITestNamesHelper.NEW).menu(UITestNamesHelper.TYPE_PROJECT).click(); final SWTBotShell shell = bot.shell(UITestNamesHelper.NEW_TYPE); shell.activate(); @@ -222,7 +224,8 @@ public void tryToCreateANewFBTypeWithExistingName() { @SuppressWarnings("static-method") @Test public void deleteExistingFBType() { - createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT4, UITestNamesHelper.ADAPTER); + new SWTBotFBType(bot).createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT4, + UITestNamesHelper.ADAPTER); final SWTBotView systemExplorerView = bot.viewById(UITestNamesHelper.SYSTEM_EXPLORER_ID); systemExplorerView.show(); final Composite systemExplorerComposite = (Composite) systemExplorerView.getWidget(); diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/DataTypeEditorTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/DataTypeEditorTests.java index c309d2d0d0..d17462465e 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/DataTypeEditorTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/DataTypeEditorTests.java @@ -13,6 +13,7 @@ *******************************************************************************/ package org.eclipse.fordiac.ide.test.ui.fbtype; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFBType; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacNatTable; import org.eclipse.nebula.widgets.nattable.NatTable; @@ -28,8 +29,12 @@ public void operationsInitialization() { TESTVAR1 = UITestNamesHelper.VAR1; TESTVAR2 = UITestNamesHelper.VAR2; TESTVAR3 = UITestNamesHelper.VAR3; - createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, UITestNamesHelper.STRUCT); - openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); + + final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); + fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, + UITestNamesHelper.STRUCT); + fbTypeBot.openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); + final Composite tableComposite = (Composite) bot.editorByTitle(UITestNamesHelper.FBT_TEST_PROJECT2).getWidget(); natTable = bot.widget(WidgetMatcherFactory.widgetOfType(NatTable.class), tableComposite); natTableBot = new SWTBot4diacNatTable(natTable); diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/ECCEditorTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/ECCEditorTests.java index fac8bff619..1b741d0b29 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/ECCEditorTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/ECCEditorTests.java @@ -18,6 +18,7 @@ import org.eclipse.fordiac.ide.test.ui.Abstract4diacUITests; import org.eclipse.fordiac.ide.test.ui.helpers.PinNamesHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFBType; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefViewer; @@ -45,9 +46,10 @@ public class ECCEditorTests extends Abstract4diacUITests { */ @BeforeAll public static void initialization() { - createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, + final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); + fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, UITestNamesHelper.TEMPLATEBASIC); - openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); + fbTypeBot.openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); final SWTBotCTabItem eccTab = bot.cTabItem(UITestNamesHelper.ECC); eccTab.activate(); eccTab.setFocus(); diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/EventInOutputsTabTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/EventInOutputsTabTests.java index 4a42b7487a..fe0f9f95a7 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/EventInOutputsTabTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/EventInOutputsTabTests.java @@ -15,8 +15,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import org.eclipse.fordiac.ide.test.ui.PropertySheetHelper; import org.eclipse.fordiac.ide.test.ui.helpers.PinNamesHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.PropertySheetHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFBType; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacNatTable; @@ -34,8 +35,10 @@ public void operationsInitialization() { TESTVAR1 = PinNamesHelper.EI1; TESTVAR2 = PinNamesHelper.EI2; TESTVAR3 = PinNamesHelper.EI3; - createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, UITestNamesHelper.ADAPTER); - openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); + final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); + fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, + UITestNamesHelper.ADAPTER); + fbTypeBot.openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); final SWTBot propertiesBot = selectTabFromInterfaceProperties(UITestNamesHelper.EVENT_IN_AND_OUTPUTS); assertNotNull(propertiesBot); bot.viewByTitle(UITestNamesHelper.PROPERTIES_TITLE).setFocus(); diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/FunctionBlocksTabTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/FunctionBlocksTabTests.java index 5b73117e1a..359a0ed34f 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/FunctionBlocksTabTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/FunctionBlocksTabTests.java @@ -15,7 +15,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import org.eclipse.fordiac.ide.test.ui.PropertySheetHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.PropertySheetHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFBType; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacNatTable; import org.eclipse.nebula.widgets.nattable.NatTable; @@ -34,9 +35,10 @@ public void operationsInitialization() { TESTVAR1 = UITestNamesHelper.INTERNALFB1; TESTVAR2 = UITestNamesHelper.INTERNALFB2; TESTVAR3 = UITestNamesHelper.INTERNALFB3; - createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, + final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); + fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, UITestNamesHelper.TEMPLATEBASIC); - openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); + fbTypeBot.openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); final SWTBot propertiesBot = selectTabFromInterfaceProperties(UITestNamesHelper.FUNCTIONAL__BLOCKS); assertNotNull(propertiesBot); bot.viewByTitle(UITestNamesHelper.PROPERTIES_TITLE).setFocus(); diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/NatTableWithEditorBehaviorTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/NatTableWithEditorBehaviorTests.java index 9fa015654a..f9e4297e20 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/NatTableWithEditorBehaviorTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/NatTableWithEditorBehaviorTests.java @@ -16,6 +16,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import org.eclipse.fordiac.ide.test.ui.Abstract4diacUITests; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFBType; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacNatTable; @@ -46,8 +47,10 @@ public abstract class NatTableWithEditorBehaviorTests extends Abstract4diacUITes @SuppressWarnings("static-method") @BeforeEach public void operationsInitialization() { - createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, UITestNamesHelper.STRUCT); - openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); + final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); + fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, + UITestNamesHelper.STRUCT); + fbTypeBot.openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); final Composite tableComposite = (Composite) bot.editorByTitle(UITestNamesHelper.FBT_TEST_PROJECT2).getWidget(); natTable = bot.widget(WidgetMatcherFactory.widgetOfType(NatTable.class), tableComposite); natTableBot = new SWTBot4diacNatTable(natTable); @@ -64,7 +67,7 @@ public void operationsInitialization() { @SuppressWarnings("static-method") @AfterEach public void resetEnvironment() { - deleteFBType(UITestNamesHelper.FBT_TEST_PROJECT2); + new SWTBotFBType(bot).deleteFBType(UITestNamesHelper.FBT_TEST_PROJECT2); } /** diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/NatTableWithoutEditorBehaviorTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/NatTableWithoutEditorBehaviorTests.java index 764b2b906f..958160d675 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/NatTableWithoutEditorBehaviorTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/NatTableWithoutEditorBehaviorTests.java @@ -13,6 +13,7 @@ package org.eclipse.fordiac.ide.test.ui.fbtype; import org.eclipse.fordiac.ide.test.ui.Abstract4diacUITests; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFBType; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacNatTable; import org.eclipse.nebula.widgets.nattable.NatTable; @@ -41,8 +42,10 @@ public class NatTableWithoutEditorBehaviorTests extends Abstract4diacUITests { @SuppressWarnings("static-method") @BeforeEach public void operationsInitialization() { - createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, UITestNamesHelper.STRUCT); - openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); + final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); + fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, + UITestNamesHelper.STRUCT); + fbTypeBot.openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); final Composite inputComposite = (Composite) bot.editorByTitle(UITestNamesHelper.FBT_TEST_PROJECT2).getWidget(); natTable = bot.widget(WidgetMatcherFactory.widgetOfType(NatTable.class), inputComposite); natTableBot = new SWTBot4diacNatTable(natTable); @@ -60,7 +63,8 @@ public void operationsInitialization() { @SuppressWarnings("static-method") @AfterEach public void resetEnvironment() { - deleteFBType(UITestNamesHelper.FBT_TEST_PROJECT2); + final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); + fbTypeBot.deleteFBType(UITestNamesHelper.FBT_TEST_PROJECT2); } /** diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/VarInAndOutputsTabTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/VarInAndOutputsTabTests.java index 6e6576249e..1c3a6daf94 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/VarInAndOutputsTabTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/VarInAndOutputsTabTests.java @@ -16,8 +16,9 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import org.eclipse.fordiac.ide.model.datatype.helper.RetainHelper.RetainTag; -import org.eclipse.fordiac.ide.test.ui.PropertySheetHelper; import org.eclipse.fordiac.ide.test.ui.helpers.PinNamesHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.PropertySheetHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFBType; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacNatTable; @@ -35,8 +36,10 @@ public void operationsInitialization() { TESTVAR1 = PinNamesHelper.DI1; TESTVAR2 = PinNamesHelper.DI2; TESTVAR3 = PinNamesHelper.DI3; - createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, UITestNamesHelper.ADAPTER); - openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); + final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); + fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, + UITestNamesHelper.ADAPTER); + fbTypeBot.openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); final SWTBot propertiesBot = selectTabFromInterfaceProperties(UITestNamesHelper.VAR_IN_AND_OUTPUTS); assertNotNull(propertiesBot); bot.viewByTitle(UITestNamesHelper.PROPERTIES_TITLE).setFocus(); diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/VarInternalsTabTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/VarInternalsTabTests.java index d41bb78158..1c64f98e31 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/VarInternalsTabTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/VarInternalsTabTests.java @@ -15,7 +15,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import org.eclipse.fordiac.ide.model.datatype.helper.RetainHelper.RetainTag; -import org.eclipse.fordiac.ide.test.ui.PropertySheetHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.PropertySheetHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFBType; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacNatTable; import org.eclipse.nebula.widgets.nattable.NatTable; @@ -32,9 +33,10 @@ public void operationsInitialization() { TESTVAR1 = UITestNamesHelper.INTERNALVAR1; TESTVAR2 = UITestNamesHelper.INTERNALVAR2; TESTVAR3 = UITestNamesHelper.INTERNALVAR3; - createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, + final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); + fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, UITestNamesHelper.TEMPLATEBASIC); - openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); + fbTypeBot.openFBTypeInEditor(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2); final SWTBot propertiesBot = selectTabFromInterfaceProperties(UITestNamesHelper.VAR_INTERNALS); assertNotNull(propertiesBot); bot.viewByTitle(UITestNamesHelper.PROPERTIES_TITLE).setFocus(); diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/PropertySheetHelper.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/PropertySheetHelper.java similarity index 98% rename from tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/PropertySheetHelper.java rename to tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/PropertySheetHelper.java index f42d20290d..7883421444 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/PropertySheetHelper.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/PropertySheetHelper.java @@ -13,7 +13,7 @@ * createEvent from * "org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusHelper" */ -package org.eclipse.fordiac.ide.test.ui; +package org.eclipse.fordiac.ide.test.ui.helpers; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Control; diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/SWTBotConnection.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/SWTBotConnection.java new file mode 100644 index 0000000000..c2e766eacb --- /dev/null +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/SWTBotConnection.java @@ -0,0 +1,193 @@ +/******************************************************************************* + * Copyright (c) 2023, 2024 Andrea Zoitl, Prashantkumar Khatri + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Andrea Zoitl - initial API and implementation and/or initial documentation + * - moved methods that are related to connections from class + * Abstract4diacUITests here due to architecture redesign and + * created constructor and fields. + * Prashantkumar Khatri - added FBType related methods + *******************************************************************************/ + +package org.eclipse.fordiac.ide.test.ui.helpers; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Map; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.fordiac.ide.test.ui.Abstract4diacUITests; +import org.eclipse.fordiac.ide.test.ui.swtbot.SWT4diacGefBot; +import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; +import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefViewer; +import org.eclipse.gef.ConnectionEditPart; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.GraphicalViewer; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; +import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; +import org.eclipse.swtbot.swt.finder.SWTBot; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; + +public class SWTBotConnection { + + private final SWT4diacGefBot bot; + + @SuppressWarnings("static-access") + public SWTBotConnection(final SWT4diacGefBot bot) { + this.bot = bot; + } + + /** + * Creates a connection between two pins. + * + * The method creates a connection between the two given pins, the order of the + * pins is not important and returns a SWTBot4diacGefViewer. Whether a + * connection could actually be created is not checked here. + * + * @param pin1 One of the two pins between a connection is (tried to) create. + * @param pin2 One of the two pins between a connection is (tried to) create. + * @return SWTBot4diacGefViewer + */ + public SWTBot4diacGefViewer createConnection(final String pin1, final String pin2) { + final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); + assertNotNull(editor); + final SWTBot4diacGefViewer viewer = (SWTBot4diacGefViewer) editor.getSWTBotGefViewer(); + assertNotNull(viewer); + // select input pin + editor.click(pin1); + final SWTBotGefEditPart ei = editor.getEditPart(pin1); + assertNotNull(ei); + final IFigure figure = ((GraphicalEditPart) ei.part()).getFigure(); + assertNotNull(figure); + final Rectangle inputPinBounds1 = figure.getBounds().getCopy(); + assertNotNull(inputPinBounds1); + figure.translateToAbsolute(inputPinBounds1); + // select output pin + editor.click(pin2); + final SWTBotGefEditPart eo = editor.getEditPart(pin2); + assertNotNull(eo); + final Rectangle inputPinBounds2 = ((GraphicalEditPart) eo.part()).getFigure().getBounds().getCopy(); + assertNotNull(inputPinBounds2); + figure.translateToAbsolute(inputPinBounds2); + viewer.drag(pin2, inputPinBounds1.getCenter().x, inputPinBounds1.getCenter().y); + checkIfConnectionCanBeFound(pin1, pin2); + return viewer; + } + + public boolean checkIfConnectionCanBeFound(final String srcPinName, final String dstPinName) { + return findConnection(srcPinName, dstPinName) != null; + } + + public ConnectionEditPart findConnection(final String srcPinName, final String dstPinName) { + final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); + final SWTBot4diacGefViewer viewer = (SWTBot4diacGefViewer) editor.getSWTBotGefViewer(); + final GraphicalViewer graphicalViewer = viewer.getGraphicalViewer(); + + return Display.getDefault().syncCall(() -> { + graphicalViewer.flush(); + final Map editPartRegistry = graphicalViewer.getEditPartRegistry(); + for (final Object obj : editPartRegistry.values()) { + if (obj instanceof final ConnectionEditPart cEP) { + // search for connection between the 2 pins + final EditPart source = cEP.getSource(); + final EditPart target = cEP.getTarget(); + + final IFigure srcFigure = ((GraphicalEditPart) source).getFigure(); + final Label srcLabel = (Label) srcFigure; + final String srcText = srcLabel.getText(); + + final IFigure dstFigure = ((GraphicalEditPart) target).getFigure(); + final Label dstLabel = (Label) dstFigure; + final String dstText = dstLabel.getText(); + + if (srcPinName.equals(srcText) && dstPinName.equals(dstText)) { + return cEP; + } + + } + } + return null; + }); + } + + /** + * Creates connection within FB Type from Property Sheet + * + * @param pin1 Name of pin1. + * @param pin2 Name of pin2. + * @param editor Selected Gef Editor + */ + public void createConnectionWithinFBTypeWithPropertySheet(final String pin1, final String pin2, + final SWTBot4diacGefEditor editor) { + + final SWTBotGefEditPart port1 = editor.getEditPart(pin1); + port1.click(); + + final SWTBotGefEditPart port2 = editor.getEditPart(pin2); + port2.click(); + + SWTBot propertiesBot = bot.viewByTitle(UITestNamesHelper.PROPERTIES_TITLE).bot(); + bot.viewByTitle(UITestNamesHelper.PROPERTIES_TITLE).setFocus(); + + if (PropertySheetHelper.selectPropertyTabItem(UITestNamesHelper.EVENT, propertiesBot)) { + propertiesBot = Abstract4diacUITests.selectTabFromInterfaceProperties(UITestNamesHelper.EVENT); + } else { + propertiesBot = Abstract4diacUITests.selectTabFromInterfaceProperties(UITestNamesHelper.DATA); + } + + // Find the group with the label "With" + final SWTBotTable table = propertiesBot.tableInGroup(UITestNamesHelper.WITH); + + table.select(pin1); + table.getTableItem(pin1).toggleCheck(); + assertTrue(table.getTableItem(pin1).isChecked()); + checkIfConnectionCanBeFound(pin1, pin2); + } + + /** + * Remove connection within FB Type from Property Sheet + * + * @param pin1 Name of pin1. + * @param pin2 Name of pin2. + * @param editor Selected Gef Editor + */ + public void removeConnectionWithinFBTypeWithPropertySheet(final String pin1, final String pin2, + final SWTBot4diacGefEditor editor) { + + final SWTBotGefEditPart port1 = editor.getEditPart(pin1); + editor.click(port1); + + final SWTBotGefEditPart port2 = editor.getEditPart(pin2); + port2.click(); + + SWTBot propertiesBot = bot.viewByTitle(UITestNamesHelper.PROPERTIES_TITLE).bot(); + bot.viewByTitle(UITestNamesHelper.PROPERTIES_TITLE).setFocus(); + + if (PropertySheetHelper.selectPropertyTabItem(UITestNamesHelper.EVENT, propertiesBot)) { + propertiesBot = Abstract4diacUITests.selectTabFromInterfaceProperties(UITestNamesHelper.EVENT); + } else { + propertiesBot = Abstract4diacUITests.selectTabFromInterfaceProperties(UITestNamesHelper.DATA); + } + + // Find the group with the label "With" + final SWTBotTable table = propertiesBot.tableInGroup(UITestNamesHelper.WITH); + + table.select(pin1); + table.getTableItem(pin1).toggleCheck(); + assertFalse(table.getTableItem(pin1).isChecked()); + checkIfConnectionCanBeFound(pin1, pin2); + } + +} diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/SWTBotFB.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/SWTBotFB.java new file mode 100644 index 0000000000..417bfa5830 --- /dev/null +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/SWTBotFB.java @@ -0,0 +1,174 @@ +/******************************************************************************* + * Copyright (c) 2023, 2024 Andrea Zoitl + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Andrea Zoitl - initial API and implementation and/or initial documentation + * - moved methods that are related to Function Blocks from class + * Abstract4diacUITests here due to architecture redesign and + * created constructor and fields. + *******************************************************************************/ + +package org.eclipse.fordiac.ide.test.ui.helpers; + +import static org.eclipse.swtbot.swt.finder.waits.Conditions.treeItemHasNode; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.util.List; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.fordiac.ide.application.editparts.FBEditPart; +import org.eclipse.fordiac.ide.test.ui.swtbot.SWT4diacGefBot; +import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; +import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefViewer; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; +import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; +import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefFigureCanvas; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.hamcrest.BaseMatcher; +import org.hamcrest.Description; + +public class SWTBotFB { + + private final SWT4diacGefBot bot; + + @SuppressWarnings("static-access") + public SWTBotFB(final SWT4diacGefBot bot) { + this.bot = bot; + } + + /** + * Drags and drops a FB onto the canvas with given name and position. + * + * @param fbName The name of the Function Block. + * @param point The Position of the FB on the canvas. + */ + @SuppressWarnings("static-access") + public void dragAndDropEventsFB(final String fbName, final Point point) { + final SWTBotSystemExplorer sysEx = new SWTBotSystemExplorer(bot); + final SWTBotTreeItem typeLibraryNode = sysEx.expandTypeLibraryTreeItemInSystemExplorer(); + bot.waitUntil(treeItemHasNode(typeLibraryNode, UITestNamesHelper.EVENTS_NODE)); + final SWTBotTreeItem eventsNode = typeLibraryNode.getNode(UITestNamesHelper.EVENTS_NODE); + eventsNode.select(); + eventsNode.expand(); + bot.waitUntil(treeItemHasNode(eventsNode, fbName)); + final SWTBotTreeItem eCycleNode = eventsNode.getNode(fbName); + eCycleNode.select(); + eCycleNode.click(); + + // select application editor + final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); + final SWTBot4diacGefViewer viewer = (SWTBot4diacGefViewer) editor.getSWTBotGefViewer(); + final SWTBotGefFigureCanvas canvas = viewer.getCanvas(); + + assertNotNull(canvas); + eCycleNode.dragAndDrop(canvas, point); + } + + /** + * Selects a FunctionBlock with the given Name in the editor. + * + * The function block is searched for with the given name in the editor. + * However, as this only selects the name, the parent is retrieved and selected. + * Only then is the searched function block selected as a whole. + * + * @param editor + * @param name + */ + @SuppressWarnings("static-method") + public SWTBot4diacGefEditor selectFBWithFBNameInEditor(final SWTBot4diacGefEditor editor, final String name) { + assertNotNull(editor); + assertNotNull(editor.getEditPart(name)); + editor.click(name); + final SWTBotGefEditPart parent = editor.getEditPart(name).parent(); + assertNotNull(parent); + editor.click(parent); + return editor; + } + + /** + * Deletes a FB from the editing area. + * + * @param editor The SWTBot4diacGefEditor from which a FB with given + * instance name should be deleted. + * @param FbInstanceName The instance name of the FB + */ + public void deleteFB(final SWTBot4diacGefEditor editor, final String FbInstanceName) { + editor.setFocus(); + final SWTBotGefEditPart fb = editor.getEditPart(FbInstanceName).parent(); + fb.select().click(); + bot.menu(UITestNamesHelper.EDIT).menu(UITestNamesHelper.DELETE).click(); + } + + /** + * Checks if FB is selected by searching selectedEditParts list and returns the + * corresponding boolean value. + * + * @param selectedEditParts The List of selected EditParts. + * @param fbName The FB that is searched for. + * @return true if fbName is in the List, otherwise false. + */ + @SuppressWarnings("static-method") + public boolean isFbSelected(final List selectedEditParts, final String fbName) { + return selectedEditParts.stream().filter(p -> p.part() instanceof FBEditPart).map(p -> (FBEditPart) p.part()) + .anyMatch(fb -> fb.getModel().getName().equals(fbName)); + } + + /** + * Checks if given FB instance name can be found on the editing area. + * + * @param editor The SWTBot4diacGefEditor in which the FB instance name is + * searched + * @param fbName The String of the FB instance name searched for + * @return true if FB is onto editing area, false if not + */ + @SuppressWarnings("static-method") + public boolean isFBNamePresendOnEditingArea(final SWTBot4diacGefEditor editor, final String fbName) { + final List editParts = editor.editParts(new BaseMatcher() { + @Override + public boolean matches(final Object item) { + return item instanceof FBEditPart; + } + + @Override + public void describeTo(final Description description) { + // method must be implemented but empty since not needed + } + }); + assertFalse(editParts.isEmpty()); + return editParts.stream().filter(p -> p.part() instanceof FBEditPart).map(p -> (FBEditPart) p.part()) + .anyMatch(fb -> fb.getModel().getName().equals(fbName)); + } + + /** + * Returns the bounds of the searched function block + * + * @param editor + * @param fBname + * @return The rectangle with the bounds of the function block searched for + */ + @SuppressWarnings("static-method") + public Rectangle getBoundsOfFB(final SWTBotGefEditor editor, final String fBname) { + editor.getEditPart(fBname); + editor.click(fBname); + final SWTBotGefEditPart parent = editor.getEditPart(fBname).parent(); + assertNotNull(parent); + final IFigure figure = ((GraphicalEditPart) parent.part()).getFigure(); + assertNotNull(figure); + final Rectangle fbBounds = figure.getBounds().getCopy(); + assertNotNull(fbBounds); + figure.translateToAbsolute(fbBounds); + return fbBounds; + } + +} diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/SWTBotFBType.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/SWTBotFBType.java new file mode 100644 index 0000000000..fb6388da16 --- /dev/null +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/SWTBotFBType.java @@ -0,0 +1,138 @@ +/******************************************************************************* + * Copyright (c) 2024 Prashantkumar Khatri, Andrea Zoitl + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Prashantkumar Khatri - initial API and implementation and/or initial documentation + * Andrea Zoitl - moved methods that are related to Function Blocks from class + * Abstract4diacUITests here due to architecture redesign and + * created constructor and fields. + *******************************************************************************/ + +package org.eclipse.fordiac.ide.test.ui.helpers; + +import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellCloses; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; + +import org.eclipse.fordiac.ide.test.ui.swtbot.SWT4diacGefBot; +import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; +import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; + +public class SWTBotFBType { + + private final SWT4diacGefBot bot; + + @SuppressWarnings("static-access") + public SWTBotFBType(final SWT4diacGefBot bot) { + this.bot = bot; + } + + /** + * Creates a New Type with given name. + * + * @param parentName Name of the parent project. + * @param typeName Name of the new type. + * @param typeLabel Name of the Type Label. + */ + public void createFBType(final String parentName, final String typeName, final String typeLabel) { + bot.menu(UITestNamesHelper.FILE).menu(UITestNamesHelper.NEW).menu(UITestNamesHelper.TYPE_PROJECT).click(); + final SWTBotShell shell = bot.shell(UITestNamesHelper.NEW_TYPE); + shell.activate(); + bot.textWithLabel(UITestNamesHelper.TYPE_NAME_LABEL).setText(typeName); + bot.textWithLabel(UITestNamesHelper.PARENT_FOLDER_NAME_LABEL).setText(parentName); + assertEquals(bot.textWithLabel(UITestNamesHelper.TYPE_NAME_LABEL).getText(), typeName); + bot.tableWithLabel(UITestNamesHelper.SELECT_TYPE_LABEL).getTableItem(typeLabel).select(); + bot.button(UITestNamesHelper.FINISH).click(); + bot.waitUntil(shellCloses(shell)); + } + + /** + * Deletes FB Type with give name. + * + * @param typeName Name of the new type. + */ + public void deleteFBType(final String typeName) { + final SWTBotView systemExplorerView = bot.viewById(UITestNamesHelper.SYSTEM_EXPLORER_ID); + systemExplorerView.show(); + final Composite systemExplorerComposite = (Composite) systemExplorerView.getWidget(); + + final Tree swtTree = bot.widget(WidgetMatcherFactory.widgetOfType(Tree.class), systemExplorerComposite); + final SWTBotTree tree = new SWTBotTree(swtTree); + final SWTBotTreeItem parentItem = tree.getTreeItem(UITestNamesHelper.PROJECT_NAME); + parentItem.expand(); + SWTBotTreeItem projectItem = null; + for (final SWTBotTreeItem item : parentItem.getItems()) { + if (item.getText().contains(typeName)) { + projectItem = item; + break; + } + } + projectItem.select(); + bot.menu(UITestNamesHelper.EDIT).menu(UITestNamesHelper.DELETE).click(); + + // the project deletion confirmation dialog + final SWTBotShell shell = bot.shell(UITestNamesHelper.DELETE_RESOURCES); + shell.activate(); + bot.button(UITestNamesHelper.OK).click(); + bot.waitUntil(shellCloses(shell)); + final List nodeList = parentItem.getNodes(); + assertFalse(nodeList.contains(typeName)); + } + + /** + * Open FB Type in editor from explorer. + * + * @param parentName Name of the parent Project. + * @param typeName Name of the new type. + */ + public void openFBTypeInEditor(final String parentName, final String typeName) { + final SWTBotView systemExplorerView = bot.viewByTitle(UITestNamesHelper.SYSTEM_EXPLORER_LABEL); + systemExplorerView.show(); + final Composite systemExplorerComposite = (Composite) systemExplorerView.getWidget(); + final Tree swtTree = bot.widget(WidgetMatcherFactory.widgetOfType(Tree.class), systemExplorerComposite); + final SWTBotTree tree = new SWTBotTree(swtTree); + final SWTBotTreeItem parentItem = tree.getTreeItem(parentName); + parentItem.expand(); + SWTBotTreeItem projectItem = null; + for (final SWTBotTreeItem item : parentItem.getItems()) { + if (item.getText().contains(typeName)) { + projectItem = item; + break; + } + } + assertTrue(projectItem.getText().contains(typeName)); + } + + /** + * Deletes the given pin on the FB opened the provided editor. + * + * @param editor Selected Gef Editor + * @param pinName Name of pin. + */ + public static void deletePin(final SWTBot4diacGefEditor editor, final String pinName) { + final SWTBotGefEditPart pin = editor.getEditPart(pinName); + assertNotNull(pin); + pin.click(); + editor.clickContextMenu(UITestNamesHelper.DELETE); + assertNull(editor.getEditPart(pinName)); + } + +} diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/SWTBotSubapp.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/SWTBotSubapp.java new file mode 100644 index 0000000000..6e0a07fedf --- /dev/null +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/SWTBotSubapp.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2023, 2024 Andrea Zoitl + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Andrea Zoitl - initial API and implementation and/or initial documentation + * - moved methods related to Subapplications from class + * Abstract4diacUITests here due to architecture redesign and + * created constructor and fields. + *******************************************************************************/ + +package org.eclipse.fordiac.ide.test.ui.helpers; + +import java.util.List; + +import org.eclipse.fordiac.ide.application.editparts.SubAppForFBNetworkEditPart; +import org.eclipse.fordiac.ide.test.ui.swtbot.SWT4diacGefBot; +import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; +import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; + +public class SWTBotSubapp { + + private final SWT4diacGefBot bot; + + public SWTBotSubapp(final SWT4diacGefBot bot) { + this.bot = bot; + } + + /** + * creates a Subapplication by first selecting all elements within the given + * rectangle and then creating the Subapplication. + * + * @param fromXPosition the x value of the starting point + * @param fromYPosition the y value of the starting point + * @param toXPosition the x value of the target point + * @param toYPosition the y value of the target point + * @return + */ + public void createSubappWithDragRectangle(final int fromXPosition, final int fromYPosition, final int toXPosition, + final int toYPosition) { + final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); + editor.drag(fromXPosition, fromYPosition, toXPosition, toYPosition); + bot.menu(UITestNamesHelper.SOURCE).menu(UITestNamesHelper.NEW_SUBAPPLICATION).click(); + } + + /** + * Checks if Subapplication is selected by searching selectedEditParts list and + * returns the corresponding boolean value. + * + * @param selectedEditParts The List of selected EditParts. + * @param subAppName The Subapplication that is searched for. + * @return true if Subapplication is in the List, otherwise false. + */ + @SuppressWarnings("static-method") + public boolean isSubappSelected(final List selectedEditParts, final String subAppName) { + return selectedEditParts.stream().filter(p -> p.part() instanceof SubAppForFBNetworkEditPart) + .map(p -> (SubAppForFBNetworkEditPart) p.part()) + .anyMatch(fb -> subAppName.equals(fb.getModel().getName())); + } + +} diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/SWTBotSystemExplorer.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/SWTBotSystemExplorer.java new file mode 100644 index 0000000000..d18e7c395c --- /dev/null +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/helpers/SWTBotSystemExplorer.java @@ -0,0 +1,180 @@ +/******************************************************************************* + * Copyright (c) 2023, 2024 Andrea Zoitl + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Andrea Zoitl - initial API and implementation and/or initial documentation + * - moved methods related to SystemExplorer from class + * Abstract4diacUITests here due to architecture redesign and + * created constructor and fields. + *******************************************************************************/ + +package org.eclipse.fordiac.ide.test.ui.helpers; + +import static org.eclipse.swtbot.swt.finder.waits.Conditions.treeItemHasNode; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.util.List; + +import org.eclipse.fordiac.ide.test.ui.swtbot.SWT4diacGefBot; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; + +public class SWTBotSystemExplorer { + + private final SWT4diacGefBot bot; + private final SWTBotView systemExplorerView; + private final SWTBotTree tree; + + /** + * Creates an instance of {@code SWTBotSystemExplorer} for interacting with the + * System Explorer view in the 4diac IDE. + * + * This constructor initializes the System Explorer view and sets up access to + * the tree structure within the view. It also ensures that the System Explorer + * view is visible. + * + * @param bot the {@code SWT4diacGefBot} instance used for interacting with the + * 4diac IDEs + * @throws AssertionError if the tree widget within the System Explorer view + * cannot be found + */ + public SWTBotSystemExplorer(final SWT4diacGefBot bot) { + this.bot = bot; + this.systemExplorerView = bot.viewById(UITestNamesHelper.SYSTEM_EXPLORER_ID); + this.systemExplorerView.show(); + final Composite systemExplorerComposite = (Composite) systemExplorerView.getWidget(); + final Tree swtTree = bot.widget(WidgetMatcherFactory.widgetOfType(Tree.class), systemExplorerComposite); + this.tree = new SWTBotTree(swtTree); + assertNotNull(tree); + } + + /** + * Checks if given element is visible in the Application of the System in the + * SystemExplorer Tree. + * + * @author Andrea Zoitl + * @param element The name of the element (function block or SubApp) searched + * for in the Application of the System in the SystemExplorer + * tree. + * @return {@code true} if node is visible in tree; {@code false} otherwise + */ + public boolean isElementInApplicationOfSystemInSystemExplorer(final String element) { + final SWTBotTreeItem appNode = expandApplicationTreeItemInSystemExplorer(); + bot.waitUntil(treeItemHasNode(appNode, element)); + final SWTBotTreeItem elementNode = appNode.getNode(element); + assertNotNull(elementNode); + return elementNode.isVisible(); + } + + /** + * Checks if given Function Block is visible in the SubApp node of the + * Application the System in the SystemExplorer Tree. + * + * @author Andrea Zoitl + * @param fbName The name of the function block searched for in the SubApp node + * of the Application in the System in the SystemExplorer tree., + * @return {@code true} if FB is visible in tree; {@code false} otherwise + */ + public boolean isFBInSubAppOfSystemInSystemExplorer(final String fbName) { + final SWTBotTreeItem subAppNode = expandSubAppTreeItemInSystemExplorer(); + final SWTBotTreeItem fbNode = subAppNode.getNode(fbName); + assertNotNull(fbNode); + return fbNode.isVisible(); + } + + /** + * Checks if Subappliacation has no children. + * + * The method checks whether the subapplication node in the SystemExplorer has + * no children. + * + * @author Andrea Zoitl + * @return {@code true} if node has no children; {@code false} otherwise + */ + public boolean isSubAppNodeInSystemExplorerEmpty() { + final SWTBotTreeItem subAppNode = expandSubAppTreeItemInSystemExplorer(); + final List subAppChildren = subAppNode.getNodes(); + return subAppChildren.isEmpty(); + } + + /** + * Expands the 4diac IDE Project node (SWTBotTreeItem) in the System Explorer + * + * @author Andrea Zoitl + * @return treeProjectItem The expanded Project node + */ + private SWTBotTreeItem expandProjectTreeItemInSystemExplorer() { + final SWTBotTreeItem treeProjectItem = tree.getTreeItem(UITestNamesHelper.PROJECT_NAME); + return treeProjectItem.select().expand(); + + } + + /** + * Expands the System node (SWTBotTreeItem) in the System Explorer + * + * @author Andrea Zoitl + * @return The expanded {@code SWTBotTreeItem} representing the system node in + * the System Explorer + */ + private SWTBotTreeItem expandSystemTreeItemInSystemExplorer() { + final SWTBotTreeItem treeProjectItem = expandProjectTreeItemInSystemExplorer(); + bot.waitUntil(treeItemHasNode(treeProjectItem, UITestNamesHelper.PROJECT_NAME_TREE_ITEM)); + final SWTBotTreeItem systemNode = treeProjectItem.getNode(UITestNamesHelper.PROJECT_NAME_TREE_ITEM); + return systemNode.select().expand(); + } + + /** + * Expands the Type Library node (SWTBotTreeItem) in the System Explorer + * + * @author Andrea Zoitl + * @return The expanded {@code SWTBotTreeItem} representing the Type Library + * node in the System Explorer + */ + public SWTBotTreeItem expandTypeLibraryTreeItemInSystemExplorer() { + final SWTBotTreeItem treeProjectItem = expandProjectTreeItemInSystemExplorer(); + bot.waitUntil(treeItemHasNode(treeProjectItem, UITestNamesHelper.TYPE_LIBRARY_NODE)); + final SWTBotTreeItem typeLibraryNode = treeProjectItem.getNode(UITestNamesHelper.TYPE_LIBRARY_NODE); + return typeLibraryNode.select().expand(); + } + + /** + * Expands the Application node (SWTBotTreeItem) in the System Explorer + * + * @author Andrea Zoitl + * @return The expanded {@code SWTBotTreeItem} representing the Application node + * in the System Explorer + */ + public SWTBotTreeItem expandApplicationTreeItemInSystemExplorer() { + final SWTBotTreeItem systemNode = expandSystemTreeItemInSystemExplorer(); + bot.waitUntil(treeItemHasNode(systemNode, UITestNamesHelper.PROJECT_NAME_APP)); + final SWTBotTreeItem appNode = systemNode.getNode(UITestNamesHelper.PROJECT_NAME_APP); + assertNotNull(appNode); + return appNode.select().expand(); + } + + /** + * Expands the Subapplication node (SWTBotTreeItem) of the 1. level of an + * Application in the System Explorer + * + * @author Andrea Zoitl + * @return The expanded {@code SWTBotTreeItem} representing the Subapplication + * (SubApp) node in the System Explorer + */ + private SWTBotTreeItem expandSubAppTreeItemInSystemExplorer() { + final SWTBotTreeItem appNode = expandApplicationTreeItemInSystemExplorer(); + final SWTBotTreeItem subAppNode = appNode.getNode(UITestNamesHelper.SUBAPP); + assertNotNull(subAppNode); + return subAppNode.select().expand(); + } + +} diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/Basic1FBNetworkEditingTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/basicfb/Basic1FBNetworkEditingTests.java similarity index 72% rename from tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/Basic1FBNetworkEditingTests.java rename to tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/basicfb/Basic1FBNetworkEditingTests.java index 7cc8136f7b..b2cda51b79 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/Basic1FBNetworkEditingTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/basicfb/Basic1FBNetworkEditingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 Andrea Zoitl + * Copyright (c) 2023, 2024 Andrea Zoitl * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -10,7 +10,7 @@ * Contributors: * Andrea Zoitl - initial API and implementation and/or initial documentation *******************************************************************************/ -package org.eclipse.fordiac.ide.test.ui; +package org.eclipse.fordiac.ide.test.ui.networkediting.basicfb; import static org.eclipse.swtbot.swt.finder.waits.Conditions.treeItemHasNode; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; @@ -26,10 +26,12 @@ import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.fordiac.ide.application.editparts.FBEditPart; import org.eclipse.fordiac.ide.application.editparts.InstanceNameEditPart; import org.eclipse.fordiac.ide.application.figures.InstanceNameFigure; +import org.eclipse.fordiac.ide.test.ui.Abstract4diacUITests; import org.eclipse.fordiac.ide.test.ui.helpers.PinNamesHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotConnection; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFB; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefViewer; @@ -104,10 +106,11 @@ public void dragAndDrop1FB() { * Checks if the FB is dragged onto the canvas is also visible in the hierarchy * tree. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void isAddedFbInProjectAppNode() { - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(300, 100)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(300, 100)); final SWTBotView systemExplorerView = bot.viewById(UITestNamesHelper.SYSTEM_EXPLORER_ID); assertNotNull(systemExplorerView); systemExplorerView.show(); @@ -135,10 +138,11 @@ public void isAddedFbInProjectAppNode() { /** * Checks if the FB is no longer on the canvas after deletion. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void deleteExistingFB() { - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(300, 100)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(300, 100)); final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); assertNotNull(editor); assertNotNull(editor.getEditPart(UITestNamesHelper.E_CYCLE_FB)); @@ -158,10 +162,11 @@ public void deleteExistingFB() { * selected as expected. Then a rectangle is drawn over the FB to check whether * the FB is selected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void selectFbViaMouseLeftClickRectangleOverFB() { - dragAndDropEventsFB(UITestNamesHelper.E_D_FF_TREE_ITEM, new Point(200, 200)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_D_FF_TREE_ITEM, new Point(200, 200)); final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); // drag rectangle next to FB, therefore FB should not be selected @@ -169,18 +174,12 @@ public void selectFbViaMouseLeftClickRectangleOverFB() { assertThrows(TimeoutException.class, () -> editor.waitForSelectedFBEditPart()); List selectedEditParts = editor.selectedEditParts(); assertTrue(selectedEditParts.isEmpty()); - assertFalse( - selectedEditParts.stream().filter(p -> p.part() instanceof FBEditPart).map(p -> (FBEditPart) p.part()) - .anyMatch(fb -> UITestNamesHelper.E_D_FF_FB.equals(fb.getModel().getName()))); - - // drag rectangle over to FB, therefore FB should be selected + assertFalse(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_D_FF_FB)); editor.drag(50, 50, 350, 350); assertDoesNotThrow(() -> editor.waitForSelectedFBEditPart()); selectedEditParts = editor.selectedEditParts(); assertFalse(selectedEditParts.isEmpty()); - assertTrue( - selectedEditParts.stream().filter(p -> p.part() instanceof FBEditPart).map(p -> (FBEditPart) p.part()) - .anyMatch(fb -> UITestNamesHelper.E_D_FF_FB.equals(fb.getModel().getName()))); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_D_FF_FB)); } /** @@ -191,10 +190,11 @@ public void selectFbViaMouseLeftClickRectangleOverFB() { * selected as expected. Then several attempts are made to click on the FB * (meaning within the FB bounds) to select the FB as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void selectFbViaMouseLeftClickOnFB() { - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(150, 250)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(150, 250)); final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); // check bounds of FB @@ -211,7 +211,7 @@ public void selectFbViaMouseLeftClickOnFB() { assertThrows(TimeoutException.class, () -> editor.waitForSelectedFBEditPart()); List selectedEditParts = editor.selectedEditParts(); assertFalse(selectedEditParts.isEmpty()); - assertFalse(isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); + assertFalse(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); // click next to the FB point = new Point(265, 350); @@ -219,7 +219,7 @@ public void selectFbViaMouseLeftClickOnFB() { assertThrows(TimeoutException.class, () -> editor.waitForSelectedFBEditPart()); selectedEditParts = editor.selectedEditParts(); assertFalse(selectedEditParts.isEmpty()); - assertFalse(isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); + assertFalse(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); // click exactly at the insertion point point = new Point(150, 250); @@ -228,7 +228,7 @@ public void selectFbViaMouseLeftClickOnFB() { assertDoesNotThrow(() -> editor.waitForSelectedFBEditPart()); selectedEditParts = editor.selectedEditParts(); assertFalse(selectedEditParts.isEmpty()); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); // click within the FB bounds but not on a pin or instance name point = new Point(170, 300); @@ -237,7 +237,7 @@ public void selectFbViaMouseLeftClickOnFB() { assertDoesNotThrow(() -> editor.waitForSelectedFBEditPart()); selectedEditParts = editor.selectedEditParts(); assertFalse(selectedEditParts.isEmpty()); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); // click within the FB bounds but not on a pin or instance name point = new Point(200, 340); @@ -246,7 +246,7 @@ public void selectFbViaMouseLeftClickOnFB() { assertDoesNotThrow(() -> editor.waitForSelectedFBEditPart()); selectedEditParts = editor.selectedEditParts(); assertFalse(selectedEditParts.isEmpty()); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); } /** @@ -258,11 +258,12 @@ public void selectFbViaMouseLeftClickOnFB() { * To achieve this it is necessary to create a draw2d.geometry Point with the * same coordinates of the swt.graphics Point. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void moveFB() { final Point pos1 = new Point(200, 200); - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, pos1); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, pos1); final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); assertNotNull(editor); assertNotNull(editor.getEditPart(UITestNamesHelper.E_CYCLE_FB)); @@ -301,10 +302,11 @@ public void moveFB() { * The method sets the default value of data input pin of type time of FB * E_CYCLE to a new value. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void editDTofECycle() { - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(200, 200)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(200, 200)); final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); assertNotNull(editor); editor.getEditPart(PinNamesHelper.DEF_VAL); @@ -322,10 +324,11 @@ public void editDTofECycle() { * The method checks if the default value of data input pin of type time of FB * E_CYCLE is displayed correctly. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void directEditorDefaultValueTest() { - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(200, 100)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(200, 100)); final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); assertNotNull(editor); editor.getEditPart(PinNamesHelper.DEF_VAL); @@ -342,10 +345,11 @@ public void directEditorDefaultValueTest() { * The method checks if the new entered value of data input pin of type time of * FB E_CYCLE is displayed correctly. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void directEditorNewValueTest() { - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(200, 100)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(200, 100)); final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); assertNotNull(editor); editor.getEditPart(PinNamesHelper.DEF_VAL); @@ -362,10 +366,11 @@ public void directEditorNewValueTest() { /** * Checks if it is possible to edit the automatically generated name of the FB */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void editFBName() { - dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, new Point(100, 100)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, new Point(100, 100)); final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); assertNotNull(editor); @@ -409,11 +414,13 @@ public void editFBName() { * {@link org.eclipse.gef.EditPartViewer#getEditPartRegistry() Map of the * registered EditParts}. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void validConnectionBetweenEventInputPinAndEventOutputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(200, 200)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.START, PinNamesHelper.EO); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(200, 200)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.START, PinNamesHelper.EO); assertDoesNotThrow(viewer::waitForConnection); } @@ -426,11 +433,13 @@ public void validConnectionBetweenEventInputPinAndEventOutputPin() { * {@link org.eclipse.gef.EditPartViewer#getEditPartRegistry() Map of the * registered EditParts}. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void validConnectionBetweenEventOutputPinAndEventInputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.EO1, PinNamesHelper.START); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.EO1, PinNamesHelper.START); assertDoesNotThrow(viewer::waitForConnection); } @@ -443,11 +452,13 @@ public void validConnectionBetweenEventOutputPinAndEventInputPin() { * {@link org.eclipse.gef.EditPartViewer#getEditPartRegistry() Map of the * registered EditParts}. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void validConnectionBetweenUintDataInputPinAndUintDataOutputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_CTUD_TREE_ITEM, new Point(150, 150)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.PV, PinNamesHelper.CV); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CTUD_TREE_ITEM, new Point(150, 150)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.PV, PinNamesHelper.CV); assertDoesNotThrow(viewer::waitForConnection); } @@ -460,25 +471,29 @@ public void validConnectionBetweenUintDataInputPinAndUintDataOutputPin() { * {@link org.eclipse.gef.EditPartViewer#getEditPartRegistry() Map of the * registered EditParts}. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void validConnectionBetweenBoolInputPinAndBoolOutputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_D_FF_TREE_ITEM, new Point(150, 150)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.D, PinNamesHelper.Q); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_D_FF_TREE_ITEM, new Point(150, 150)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.D, PinNamesHelper.Q); assertDoesNotThrow(viewer::waitForConnection); } /** * Checks if the connection is still there after moving the FB */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void connectionCanBeFoundAfterMovingFB() { // in progress final Point pos1 = new Point(100, 150); - dragAndDropEventsFB(UITestNamesHelper.E_TABLE_CTRL_TREE_ITEM, pos1); - createConnection(PinNamesHelper.INIT, PinNamesHelper.CLKO); - createConnection(PinNamesHelper.N, PinNamesHelper.CV); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_TABLE_CTRL_TREE_ITEM, pos1); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + connectBot.createConnection(PinNamesHelper.INIT, PinNamesHelper.CLKO); + connectBot.createConnection(PinNamesHelper.N, PinNamesHelper.CV); final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); final SWTBot4diacGefViewer viewer = (SWTBot4diacGefViewer) editor.getSWTBotGefViewer(); @@ -487,8 +502,8 @@ public void connectionCanBeFoundAfterMovingFB() { assertNotNull(canvas); canvas.setFocus(); - assertTrue(checkIfConnectionCanBeFound(PinNamesHelper.CLKO, PinNamesHelper.INIT)); - assertTrue(checkIfConnectionCanBeFound(PinNamesHelper.CV, PinNamesHelper.N)); + assertTrue(connectBot.checkIfConnectionCanBeFound(PinNamesHelper.CLKO, PinNamesHelper.INIT)); + assertTrue(connectBot.checkIfConnectionCanBeFound(PinNamesHelper.CV, PinNamesHelper.N)); assertNotNull(editor); assertNotNull(editor.getEditPart(UITestNamesHelper.E_TABLE_CTRL_FB)); @@ -520,8 +535,8 @@ public void connectionCanBeFoundAfterMovingFB() { assertEquals(posToCheck2.x, fbBounds.x); assertEquals(posToCheck2.y, fbBounds.y); - assertTrue(checkIfConnectionCanBeFound(PinNamesHelper.CLKO, PinNamesHelper.INIT)); - assertTrue(checkIfConnectionCanBeFound(PinNamesHelper.CV, PinNamesHelper.N)); + assertTrue(connectBot.checkIfConnectionCanBeFound(PinNamesHelper.CLKO, PinNamesHelper.INIT)); + assertTrue(connectBot.checkIfConnectionCanBeFound(PinNamesHelper.CV, PinNamesHelper.N)); } /** @@ -534,11 +549,13 @@ public void connectionCanBeFoundAfterMovingFB() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenEventInputPinAndEventInputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.START, PinNamesHelper.STOP); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.START, PinNamesHelper.STOP); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -552,11 +569,13 @@ public void invalidConnectionBetweenEventInputPinAndEventInputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenEventInputPinAndUintInputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(150, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.START, PinNamesHelper.N); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(150, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.START, PinNamesHelper.N); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -570,11 +589,13 @@ public void invalidConnectionBetweenEventInputPinAndUintInputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenEventInputPinAndTimeInputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(150, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.START, PinNamesHelper.DT); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(150, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.START, PinNamesHelper.DT); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -588,11 +609,13 @@ public void invalidConnectionBetweenEventInputPinAndTimeInputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenEventInputPinAndBoolInputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_D_FF_TREE_ITEM, new Point(150, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.CLK, PinNamesHelper.D); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_D_FF_TREE_ITEM, new Point(150, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.CLK, PinNamesHelper.D); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -606,11 +629,13 @@ public void invalidConnectionBetweenEventInputPinAndBoolInputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenEventInputPinAndUintOutputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_CTUD_TREE_ITEM, new Point(100, 150)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.CD, PinNamesHelper.CV); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CTUD_TREE_ITEM, new Point(100, 150)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.CD, PinNamesHelper.CV); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -624,11 +649,13 @@ public void invalidConnectionBetweenEventInputPinAndUintOutputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenEventInputPinAndTimeOutputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_TABLE_CTRL_TREE_ITEM, new Point(100, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.INIT, PinNamesHelper.DTO); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_TABLE_CTRL_TREE_ITEM, new Point(100, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.INIT, PinNamesHelper.DTO); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -642,11 +669,13 @@ public void invalidConnectionBetweenEventInputPinAndTimeOutputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenEventInputPinAndBoolOutputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_CTUD_TREE_ITEM, new Point(100, 150)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.CD, PinNamesHelper.QU); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CTUD_TREE_ITEM, new Point(100, 150)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.CD, PinNamesHelper.QU); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -660,11 +689,13 @@ public void invalidConnectionBetweenEventInputPinAndBoolOutputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenTimeInputPinAndTimeOutputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_TABLE_CTRL_TREE_ITEM, new Point(100, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.DT, PinNamesHelper.DTO); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_TABLE_CTRL_TREE_ITEM, new Point(100, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.DT, PinNamesHelper.DTO); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -678,11 +709,13 @@ public void invalidConnectionBetweenTimeInputPinAndTimeOutputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenTimeInputPinAndUintInputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.DT, PinNamesHelper.N); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.DT, PinNamesHelper.N); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -696,11 +729,13 @@ public void invalidConnectionBetweenTimeInputPinAndUintInputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenUintInputPinAndBoolOutputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_CTUD_TREE_ITEM, new Point(100, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.PV, PinNamesHelper.QU); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CTUD_TREE_ITEM, new Point(100, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.PV, PinNamesHelper.QU); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -714,11 +749,13 @@ public void invalidConnectionBetweenUintInputPinAndBoolOutputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenEventOutputPinAndUintInputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.EO0, PinNamesHelper.N); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.EO0, PinNamesHelper.N); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -732,11 +769,13 @@ public void invalidConnectionBetweenEventOutputPinAndUintInputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenEventOutputPinAndTimeInputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.EO1, PinNamesHelper.DT); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.EO1, PinNamesHelper.DT); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -750,11 +789,13 @@ public void invalidConnectionBetweenEventOutputPinAndTimeInputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenEventOutputPinAndBoolInputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_D_FF_TREE_ITEM, new Point(100, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.EO, PinNamesHelper.D); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_D_FF_TREE_ITEM, new Point(100, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.EO, PinNamesHelper.D); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -768,11 +809,13 @@ public void invalidConnectionBetweenEventOutputPinAndBoolInputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenEventOutputPinAndEventOutputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.EO0, PinNamesHelper.EO2); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.EO0, PinNamesHelper.EO2); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -786,11 +829,13 @@ public void invalidConnectionBetweenEventOutputPinAndEventOutputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenEventOutputPinAndUintOutputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_TABLE_CTRL_TREE_ITEM, new Point(100, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.CLKO, PinNamesHelper.CV); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_TABLE_CTRL_TREE_ITEM, new Point(100, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.CLKO, PinNamesHelper.CV); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -804,11 +849,13 @@ public void invalidConnectionBetweenEventOutputPinAndUintOutputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenEventOutputPinAndTimeOutputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_TABLE_CTRL_TREE_ITEM, new Point(100, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.CLKO, PinNamesHelper.DTO); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_TABLE_CTRL_TREE_ITEM, new Point(100, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.CLKO, PinNamesHelper.DTO); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -822,11 +869,13 @@ public void invalidConnectionBetweenEventOutputPinAndTimeOutputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenEventOutputPinAndBoolOutputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_D_FF_TREE_ITEM, new Point(100, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.EO, PinNamesHelper.Q); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_D_FF_TREE_ITEM, new Point(100, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.EO, PinNamesHelper.Q); assertThrows(TimeoutException.class, viewer::waitForConnection); } @@ -840,11 +889,13 @@ public void invalidConnectionBetweenEventOutputPinAndBoolOutputPin() { * map of the {@link EditPartViewer#getEditPartRegistry * EditPartRegistry} as expected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void invalidConnectionBetweenBoolOutputPinAndBoolOutputPin() { - dragAndDropEventsFB(UITestNamesHelper.E_CTUD_TREE_ITEM, new Point(100, 100)); - final SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.QU, PinNamesHelper.QD); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CTUD_TREE_ITEM, new Point(100, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.QU, PinNamesHelper.QD); assertThrows(TimeoutException.class, viewer::waitForConnection); } diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/Basic2FBNetworkEditingTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/basicfb/Basic2FBNetworkEditingTests.java similarity index 73% rename from tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/Basic2FBNetworkEditingTests.java rename to tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/basicfb/Basic2FBNetworkEditingTests.java index ab389d7a9e..1190f98bc7 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/Basic2FBNetworkEditingTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/basicfb/Basic2FBNetworkEditingTests.java @@ -10,9 +10,8 @@ * Contributors: * Andrea Zoitl - initial API and implementation and/or initial documentation *******************************************************************************/ -package org.eclipse.fordiac.ide.test.ui; +package org.eclipse.fordiac.ide.test.ui.networkediting.basicfb; -import static org.eclipse.swtbot.swt.finder.waits.Conditions.treeItemHasNode; import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -25,21 +24,16 @@ import org.eclipse.draw2d.PolylineConnection; import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.fordiac.ide.test.ui.Abstract4diacUITests; import org.eclipse.fordiac.ide.test.ui.helpers.PinNamesHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotConnection; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFB; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; -import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefViewer; import org.eclipse.gef.ConnectionEditPart; import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory; -import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefFigureCanvas; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; import org.eclipse.swtbot.swt.finder.widgets.TimeoutException; import org.junit.jupiter.api.Test; @@ -54,56 +48,24 @@ public class Basic2FBNetworkEditingTests extends Abstract4diacUITests { * Then a second FB (E_SWITCH) is dragged onto the canvas and the check is the * same as above. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void dragAndDrop2FB() { // select FB E_CYCLE - final SWTBotView systemExplorerView = bot.viewById(UITestNamesHelper.SYSTEM_EXPLORER_ID); - systemExplorerView.show(); - final Composite systemExplorerComposite = (Composite) systemExplorerView.getWidget(); - final Tree swtTree = bot.widget(WidgetMatcherFactory.widgetOfType(Tree.class), systemExplorerComposite); - final SWTBotTree tree = new SWTBotTree(swtTree); - assertNotNull(tree); - final SWTBotTreeItem treeProjectItem = tree.getTreeItem(UITestNamesHelper.PROJECT_NAME); - assertNotNull(treeProjectItem); - treeProjectItem.select(); - treeProjectItem.expand(); - final SWTBotTreeItem typeLibraryNode = treeProjectItem.getNode(UITestNamesHelper.TYPE_LIBRARY_NODE); - assertNotNull(typeLibraryNode); - typeLibraryNode.select(); - typeLibraryNode.expand(); - final SWTBotTreeItem eventsNode = typeLibraryNode.getNode(UITestNamesHelper.EVENTS_NODE); - assertNotNull(eventsNode); - eventsNode.select(); - eventsNode.expand(); - bot.waitUntil(treeItemHasNode(eventsNode, UITestNamesHelper.E_CYCLE_TREE_ITEM)); - final SWTBotTreeItem eCycleNode = eventsNode.getNode(UITestNamesHelper.E_CYCLE_TREE_ITEM); - assertNotNull(eCycleNode); - eCycleNode.select(); - eCycleNode.click(); - // select application editor - final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); - assertNotNull(editor); - final SWTBot4diacGefViewer viewer = (SWTBot4diacGefViewer) editor.getSWTBotGefViewer(); - assertNotNull(viewer); - final SWTBotGefFigureCanvas canvas = viewer.getCanvas(); - assertNotNull(canvas); + final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); + final SWTBotFB fbBot = new SWTBotFB(bot); final Point point1 = new Point(100, 100); - eCycleNode.dragAndDrop(canvas, point1); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, point1); assertNotNull(editor.getEditPart(UITestNamesHelper.E_CYCLE_FB)); - final Rectangle absPos1 = getAbsolutePosition(editor, UITestNamesHelper.E_CYCLE_FB); + final Rectangle absPos1 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_CYCLE_FB); assertEquals(point1.x, absPos1.x); assertEquals(point1.y, absPos1.y); // select FB E_SWITCH - final SWTBotTreeItem eSwitchNode = eventsNode.getNode(UITestNamesHelper.E_SWITCH_TREE_ITEM); - assertNotNull(eSwitchNode); - eSwitchNode.select(); - eSwitchNode.click(); final Point point2 = new Point(300, 150); - eSwitchNode.dragAndDrop(canvas, point2); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, point2); assertNotNull(editor.getEditPart(UITestNamesHelper.E_SWITCH_FB)); - final Rectangle absPos2 = getAbsolutePosition(editor, UITestNamesHelper.E_SWITCH_FB); + final Rectangle absPos2 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_SWITCH_FB); assertEquals(point2.x, absPos2.x); assertEquals(point2.y, absPos2.y); } @@ -113,11 +75,12 @@ public void dragAndDrop2FB() { * deleted and it is checked if the FB is no longer on the canvas after * deletion. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void delete1FB() { - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(300, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(100, 100)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(300, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(100, 100)); final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); assertNotNull(editor); assertNotNull(editor.getEditPart(UITestNamesHelper.E_CYCLE_FB)); @@ -141,11 +104,12 @@ public void delete1FB() { * selected as expected. Then a rectangle is drawn over the FBs to check whether * the FBs are selected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void select2FBsViaMouseLeftClickOnFB() { - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_CTUD_TREE_ITEM, new Point(300, 100)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CTUD_TREE_ITEM, new Point(300, 100)); final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); // drag rectangle next to FBs, therefore FBs should not be selected @@ -153,16 +117,16 @@ public void select2FBsViaMouseLeftClickOnFB() { assertThrows(TimeoutException.class, editor::waitForSelectedFBEditPart); List selectedEditParts = editor.selectedEditParts(); assertTrue(selectedEditParts.isEmpty()); - assertFalse(isFbSelected(selectedEditParts, UITestNamesHelper.E_N_TABLE_FB)); - assertFalse(isFbSelected(selectedEditParts, UITestNamesHelper.E_CTUD_FB)); + assertFalse(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_N_TABLE_FB)); + assertFalse(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_CTUD_FB)); // drag rectangle over FBs, therefore FBs should be selected editor.drag(50, 50, 500, 300); assertDoesNotThrow(editor::waitForSelectedFBEditPart); selectedEditParts = editor.selectedEditParts(); assertFalse(selectedEditParts.isEmpty()); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_N_TABLE_FB)); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_CTUD_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_N_TABLE_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_CTUD_FB)); } /** @@ -175,13 +139,14 @@ public void select2FBsViaMouseLeftClickOnFB() { * which is not expected. To achieve this it is necessary to create a * draw2d.geometry Point with the same coordinates of the swt.graphics Point. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void move1FB() { final Point pos1 = new Point(100, 100); - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, pos1); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, pos1); final Point pos2 = new Point(350, 100); - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, pos2); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, pos2); // select E_CYCLE and check position of E_CYCLE final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); @@ -190,17 +155,17 @@ public void move1FB() { editor.click(UITestNamesHelper.E_CYCLE_FB); final SWTBotGefEditPart fb1 = editor.getEditPart(UITestNamesHelper.E_CYCLE_FB).parent(); assertNotNull(fb1); - final Rectangle fb1Bounds1 = getAbsolutePosition(editor, UITestNamesHelper.E_CYCLE_FB); + final Rectangle fb1Bounds1 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_CYCLE_FB); assertTrue(fb1Bounds1.contains(pos1.x, pos1.y)); // check position of E_N_TABLE - final Rectangle fb2Bounds1 = getAbsolutePosition(editor, UITestNamesHelper.E_N_TABLE_FB); + final Rectangle fb2Bounds1 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_N_TABLE_FB); assertTrue(fb2Bounds1.contains(pos2.x, pos2.y)); // move E_CYCLE and check new position final Point pos3 = new Point(125, 185); editor.drag(fb1, pos3.x, pos3.y); - final Rectangle fb1Bounds2 = getAbsolutePosition(editor, UITestNamesHelper.E_CYCLE_FB); + final Rectangle fb1Bounds2 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_CYCLE_FB); assertTrue(fb1Bounds2.contains(pos3.x, pos3.y)); // check if E_N_TABLE is still on same position @@ -216,37 +181,38 @@ public void move1FB() { * this position is also checked. To achieve this it is necessary to create a * draw2d.geometry Point with the same coordinates of the swt.graphics Point. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void moveBothFBOneAfterAnother() { final Point pos1 = new Point(200, 200); - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, pos1); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, pos1); final Point pos2 = new Point(400, 200); - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, pos2); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, pos2); // select and move E_CYCLE - final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); + final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); assertNotNull(editor); assertNotNull(editor.getEditPart(UITestNamesHelper.E_CYCLE_FB)); editor.click(UITestNamesHelper.E_CYCLE_FB); final SWTBotGefEditPart fb1 = editor.getEditPart(UITestNamesHelper.E_CYCLE_FB).parent(); assertNotNull(fb1); - final Rectangle fb1Bounds1 = getAbsolutePosition(editor, UITestNamesHelper.E_CYCLE_FB); + final Rectangle fb1Bounds1 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_CYCLE_FB); assertTrue(fb1Bounds1.contains(pos1.x, pos1.y)); final Point pos3 = new Point(85, 85); editor.drag(fb1, pos3.x, pos3.y); - final Rectangle fb1Bounds2 = getAbsolutePosition(editor, UITestNamesHelper.E_CYCLE_FB); + final Rectangle fb1Bounds2 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_CYCLE_FB); assertTrue(fb1Bounds2.contains(pos3.x, pos3.y)); // select and move E_SWITCH editor.click(UITestNamesHelper.E_SWITCH_FB); final SWTBotGefEditPart fb2 = editor.getEditPart(UITestNamesHelper.E_SWITCH_FB).parent(); assertNotNull(fb2); - final Rectangle fb2Bounds1 = getAbsolutePosition(editor, UITestNamesHelper.E_SWITCH_FB); + final Rectangle fb2Bounds1 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_SWITCH_FB); assertTrue(fb2Bounds1.contains(pos2.x, pos2.y)); final Point pos4 = new Point(285, 85); editor.drag(fb2, pos4.x, pos4.y); - final Rectangle fb2Bounds2 = getAbsolutePosition(editor, UITestNamesHelper.E_SWITCH_FB); + final Rectangle fb2Bounds2 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_SWITCH_FB); assertTrue(fb2Bounds2.contains(pos4.x, pos4.y)); } @@ -258,18 +224,19 @@ public void moveBothFBOneAfterAnother() { * selected as expected. Then a rectangle is drawn over the FBs to check whether * the FBs are selected. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void moveBothFBTogether() { final Point absPos1Fb1 = new Point(100, 100); - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, absPos1Fb1); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, absPos1Fb1); final Point absPos1Fb2 = new Point(100, 220); - dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, absPos1Fb2); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, absPos1Fb2); final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); - final Rectangle fb1Bounds1 = getAbsolutePosition(editor, UITestNamesHelper.E_CYCLE_FB); + final Rectangle fb1Bounds1 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_CYCLE_FB); assertTrue(fb1Bounds1.contains(absPos1Fb1.x, absPos1Fb1.y)); - final Rectangle fb2Bounds1 = getAbsolutePosition(editor, UITestNamesHelper.E_SR_FB); + final Rectangle fb2Bounds1 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_SR_FB); assertTrue(fb2Bounds1.contains(absPos1Fb2.x, absPos1Fb2.y)); // drag rectangle over FBs, therefore FBs should be selected @@ -277,8 +244,8 @@ public void moveBothFBTogether() { assertDoesNotThrow(editor::waitForSelectedFBEditPart); List selectedEditParts = editor.selectedEditParts(); assertFalse(selectedEditParts.isEmpty()); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_CYCLE_FB)); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_SR_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_CYCLE_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_SR_FB)); // move selection by clicking on point within selection (120, 120) and drag to // new Point (285, 85) @@ -289,8 +256,8 @@ public void moveBothFBTogether() { assertDoesNotThrow(editor::waitForSelectedFBEditPart); selectedEditParts = editor.selectedEditParts(); assertFalse(selectedEditParts.isEmpty()); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_CYCLE_FB)); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_SR_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_CYCLE_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_SR_FB)); // Calculation of translation final int translationX = pointTo.x - pointFrom.x; @@ -299,7 +266,7 @@ public void moveBothFBTogether() { // Calculation of new Position of E_CYCLEs final int absPos2Fb1X = absPos1Fb1.x + translationX; final int absPos2Fb1Y = absPos1Fb1.y + translationY; - final Rectangle fb1Bounds2 = getAbsolutePosition(editor, UITestNamesHelper.E_CYCLE_FB); + final Rectangle fb1Bounds2 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_CYCLE_FB); assertEquals(absPos2Fb1X, fb1Bounds2.x); assertEquals(absPos2Fb1Y, fb1Bounds2.y); assertTrue(fb1Bounds2.contains(absPos2Fb1X, absPos2Fb1Y)); @@ -307,7 +274,7 @@ public void moveBothFBTogether() { // Calculation of new Position of E_SR final int absPos2Fb2X = absPos1Fb2.x + translationX; final int absPos2Fb2Y = absPos1Fb2.y + translationY; - final Rectangle fb2Bounds2 = getAbsolutePosition(editor, UITestNamesHelper.E_SR_FB); + final Rectangle fb2Bounds2 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_SR_FB); assertEquals(absPos2Fb2X, fb2Bounds2.x); assertEquals(absPos2Fb2Y, fb2Bounds2.y); assertTrue(fb2Bounds2.contains(absPos2Fb2X, absPos2Fb2Y)); @@ -324,14 +291,16 @@ public void moveBothFBTogether() { * Then the E_CYCLE is moved and it is checked whether the start point of the * connection has also moved and whether the end point has remained unchanged. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void checkIfConnectionRemainsAfterMoving1FB() { final Point pos1 = new Point(100, 50); - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, pos1); - dragAndDropEventsFB(UITestNamesHelper.E_DEMUX_TREE_ITEM, new Point(300, 50)); - createConnection(PinNamesHelper.EO, PinNamesHelper.EI); - final ConnectionEditPart connection = findConnection(PinNamesHelper.EO, PinNamesHelper.EI); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, pos1); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_DEMUX_TREE_ITEM, new Point(300, 50)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + connectBot.createConnection(PinNamesHelper.EO, PinNamesHelper.EI); + final ConnectionEditPart connection = connectBot.findConnection(PinNamesHelper.EO, PinNamesHelper.EI); assertNotNull(connection); // select E_CYCLE @@ -341,7 +310,7 @@ public void checkIfConnectionRemainsAfterMoving1FB() { editor.click(UITestNamesHelper.E_CYCLE_FB); final SWTBotGefEditPart fb1 = editor.getEditPart(UITestNamesHelper.E_CYCLE_FB).parent(); assertNotNull(fb1); - final Rectangle fb1Bounds1 = getAbsolutePosition(editor, UITestNamesHelper.E_CYCLE_FB); + final Rectangle fb1Bounds1 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_CYCLE_FB); assertTrue(fb1Bounds1.contains(pos1.x, pos1.y)); // get connection start and end point @@ -356,7 +325,7 @@ public void checkIfConnectionRemainsAfterMoving1FB() { // move E_CYCLE editor.drag(fb1, pos2.x, pos2.y); - final Rectangle fb1Bounds2 = getAbsolutePosition(editor, UITestNamesHelper.E_CYCLE_FB); + final Rectangle fb1Bounds2 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_CYCLE_FB); assertTrue(fb1Bounds2.contains(pos2.x, pos2.y)); assertNotNull(connection); final org.eclipse.draw2d.geometry.Point newStartPointConnection = polyLineConnection.getPoints() @@ -382,15 +351,17 @@ public void checkIfConnectionRemainsAfterMoving1FB() { * Afterwards, the E_SWITCH is also moved and checked whether the start point * and end point of the connection match the new positions of the FBs. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void checkIfConnectionRemainsAfterMovingBothFBsOneAfterAnother() { final Point pos1 = new Point(375, 75); - dragAndDropEventsFB(UITestNamesHelper.E_SELECT_TREE_ITEM, pos1); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SELECT_TREE_ITEM, pos1); final Point pos2 = new Point(175, 125); - dragAndDropEventsFB(UITestNamesHelper.E_CTUD_TREE_ITEM, pos2); - createConnection(PinNamesHelper.QU, PinNamesHelper.G); - final ConnectionEditPart connection = findConnection(PinNamesHelper.QU, PinNamesHelper.G); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CTUD_TREE_ITEM, pos2); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + connectBot.createConnection(PinNamesHelper.QU, PinNamesHelper.G); + final ConnectionEditPart connection = connectBot.findConnection(PinNamesHelper.QU, PinNamesHelper.G); assertNotNull(connection); // select E_SELECT @@ -401,7 +372,7 @@ public void checkIfConnectionRemainsAfterMovingBothFBsOneAfterAnother() { editor.click(UITestNamesHelper.E_SELECT_FB); final SWTBotGefEditPart fb1 = editor.getEditPart(UITestNamesHelper.E_SELECT_FB).parent(); assertNotNull(fb1); - final Rectangle fb1Bounds1 = getAbsolutePosition(editor, UITestNamesHelper.E_SELECT_FB); + final Rectangle fb1Bounds1 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_SELECT_FB); assertTrue(fb1Bounds1.contains(pos1.x, pos1.y)); // get connection start and end point @@ -420,7 +391,7 @@ public void checkIfConnectionRemainsAfterMovingBothFBsOneAfterAnother() { // move E_SELECT editor.drag(fb1, pos3.x, pos3.y); - final Rectangle fb1Bounds2 = getAbsolutePosition(editor, UITestNamesHelper.E_SELECT_FB); + final Rectangle fb1Bounds2 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_SELECT_FB); assertTrue(fb1Bounds2.contains(pos3.x, pos3.y)); assertNotNull(connection); org.eclipse.draw2d.geometry.Point newStartPointConnection = polyLineConnection.getPoints().getFirstPoint(); @@ -434,11 +405,11 @@ public void checkIfConnectionRemainsAfterMovingBothFBsOneAfterAnother() { editor.click(UITestNamesHelper.E_CTUD_FB); final SWTBotGefEditPart fb2 = editor.getEditPart(UITestNamesHelper.E_CTUD_FB).parent(); assertNotNull(fb2); - final Rectangle fb2Bounds1 = getAbsolutePosition(editor, UITestNamesHelper.E_CTUD_FB); + final Rectangle fb2Bounds1 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_CTUD_FB); assertTrue(fb2Bounds1.contains(pos2.x, pos2.y)); // move E_CTUD editor.drag(fb2, pos4.x, pos4.y); - final Rectangle fb2Bounds2 = getAbsolutePosition(editor, UITestNamesHelper.E_CTUD_FB); + final Rectangle fb2Bounds2 = fbBot.getBoundsOfFB(editor, UITestNamesHelper.E_CTUD_FB); assertTrue(fb2Bounds2.contains(pos4.x, pos4.y)); assertNotNull(connection); newStartPointConnection = polyLineConnection.getPoints().getFirstPoint(); @@ -459,15 +430,17 @@ public void checkIfConnectionRemainsAfterMovingBothFBsOneAfterAnother() { * FB and moved to a new position. The translation is calculated and compared * with the new values of the connection start and end point. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void checkIfConnectionRemainsAfterMovingBothFBsTogether() { final Point pos1 = new Point(200, 100); - dragAndDropEventsFB(UITestNamesHelper.E_DEMUX_TREE_ITEM, pos1); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_DEMUX_TREE_ITEM, pos1); final Point pos2 = new Point(100, 275); - dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, pos2); - createConnection(PinNamesHelper.EO1, PinNamesHelper.R); - ConnectionEditPart connection = findConnection(PinNamesHelper.EO1, PinNamesHelper.R); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, pos2); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + connectBot.createConnection(PinNamesHelper.EO1, PinNamesHelper.R); + ConnectionEditPart connection = connectBot.findConnection(PinNamesHelper.EO1, PinNamesHelper.R); assertNotNull(connection); final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); @@ -481,8 +454,8 @@ public void checkIfConnectionRemainsAfterMovingBothFBsTogether() { assertDoesNotThrow(editor::waitForSelectedFBEditPart); List selectedEditParts = editor.selectedEditParts(); assertFalse(selectedEditParts.isEmpty()); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_DEMUX_FB)); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_SR_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_DEMUX_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_SR_FB)); // move selection by clicking on one FB but not on instance name or a pin final Point pointFrom = new Point(125, 300); @@ -492,15 +465,15 @@ public void checkIfConnectionRemainsAfterMovingBothFBsTogether() { assertDoesNotThrow(editor::waitForSelectedFBEditPart); selectedEditParts = editor.selectedEditParts(); assertFalse(selectedEditParts.isEmpty()); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_DEMUX_FB)); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_SR_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_DEMUX_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_SR_FB)); // calculation of translation final int translationX = pointTo.x - pointFrom.x; final int translationY = pointTo.y - pointFrom.y; // check if connection has been moved - connection = findConnection(PinNamesHelper.EO1, PinNamesHelper.R); + connection = connectBot.findConnection(PinNamesHelper.EO1, PinNamesHelper.R); assertNotNull(connection); final org.eclipse.draw2d.geometry.Point newStartPointConnection = polyLineConnection.getPoints() .getFirstPoint(); diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/BasicMultipleFBNetworkEditingTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/basicfb/BasicMultipleFBNetworkEditingTests.java similarity index 50% rename from tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/BasicMultipleFBNetworkEditingTests.java rename to tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/basicfb/BasicMultipleFBNetworkEditingTests.java index 62b3ffe31b..dd0e4e77cd 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/BasicMultipleFBNetworkEditingTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/basicfb/BasicMultipleFBNetworkEditingTests.java @@ -10,12 +10,14 @@ * Contributors: * Andrea Zoitl - initial API and implementation and/or initial documentation *******************************************************************************/ -package org.eclipse.fordiac.ide.test.ui; +package org.eclipse.fordiac.ide.test.ui.networkediting.basicfb; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import org.eclipse.fordiac.ide.test.ui.Abstract4diacUITests; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFB; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; import org.eclipse.swt.graphics.Point; @@ -50,28 +52,29 @@ public class BasicMultipleFBNetworkEditingTests extends Abstract4diacUITests { * First multiple E_CYCLE and E_SR are dragged in mixed order onto the editing * area. After that it is checked if the names were assigned correctly. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void checkIfNewFbGetsNextFreeRunningNumber() { - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(100, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, new Point(300, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(500, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(100, 250)); - dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, new Point(300, 250)); - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(500, 250)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(100, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, new Point(300, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(500, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(100, 250)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, new Point(300, 250)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(500, 250)); final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); assertNotNull(editor); - assertTrue(isFBNamePresendOnEditingArea(editor, E_CYCLE)); - assertTrue(isFBNamePresendOnEditingArea(editor, E_CYCLE_1)); - assertTrue(isFBNamePresendOnEditingArea(editor, E_CYCLE_2)); - assertTrue(isFBNamePresendOnEditingArea(editor, E_CYCLE_3)); - assertFalse(isFBNamePresendOnEditingArea(editor, E_CYCLE_0)); + assertTrue(fbBot.isFBNamePresendOnEditingArea(editor, E_CYCLE)); + assertTrue(fbBot.isFBNamePresendOnEditingArea(editor, E_CYCLE_1)); + assertTrue(fbBot.isFBNamePresendOnEditingArea(editor, E_CYCLE_2)); + assertTrue(fbBot.isFBNamePresendOnEditingArea(editor, E_CYCLE_3)); + assertFalse(fbBot.isFBNamePresendOnEditingArea(editor, E_CYCLE_0)); - assertTrue(isFBNamePresendOnEditingArea(editor, E_SR)); - assertTrue(isFBNamePresendOnEditingArea(editor, E_SR_1)); - assertFalse(isFBNamePresendOnEditingArea(editor, E_SR_2)); + assertTrue(fbBot.isFBNamePresendOnEditingArea(editor, E_SR)); + assertTrue(fbBot.isFBNamePresendOnEditingArea(editor, E_SR_1)); + assertFalse(fbBot.isFBNamePresendOnEditingArea(editor, E_SR_2)); } @@ -85,42 +88,43 @@ public void checkIfNewFbGetsNextFreeRunningNumber() { * 2 FBs are deleted and 4 FBs are added and it is checked whether the name * allocation is correct here as well. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void checkIfNewFbGetsSmallestNextFreeRunningNumber() { - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(50, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(250, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(450, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(50, 250)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(50, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(250, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(450, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(50, 250)); final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); assertNotNull(editor); - assertTrue(isFBNamePresendOnEditingArea(editor, E_SWITCH)); - assertTrue(isFBNamePresendOnEditingArea(editor, E_SWITCH_1)); - assertTrue(isFBNamePresendOnEditingArea(editor, E_SWITCH_2)); - assertTrue(isFBNamePresendOnEditingArea(editor, E_SWITCH_3)); - assertFalse(isFBNamePresendOnEditingArea(editor, E_SWITCH_0)); - assertFalse(isFBNamePresendOnEditingArea(editor, E_SWITCH_4)); - - deleteFB(editor, E_SWITCH_2); - assertFalse(isFBNamePresendOnEditingArea(editor, E_SWITCH_2)); - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(450, 250)); - assertTrue(isFBNamePresendOnEditingArea(editor, E_SWITCH_2)); - - deleteFB(editor, E_SWITCH); - deleteFB(editor, E_SWITCH_1); - assertFalse(isFBNamePresendOnEditingArea(editor, E_SWITCH)); - assertFalse(isFBNamePresendOnEditingArea(editor, E_SWITCH_1)); - - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(450, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(250, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(250, 250)); - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(50, 100)); - assertTrue(isFBNamePresendOnEditingArea(editor, E_SWITCH)); - assertTrue(isFBNamePresendOnEditingArea(editor, E_SWITCH_1)); - assertTrue(isFBNamePresendOnEditingArea(editor, E_SWITCH_4)); - assertTrue(isFBNamePresendOnEditingArea(editor, E_SWITCH_5)); + assertTrue(fbBot.isFBNamePresendOnEditingArea(editor, E_SWITCH)); + assertTrue(fbBot.isFBNamePresendOnEditingArea(editor, E_SWITCH_1)); + assertTrue(fbBot.isFBNamePresendOnEditingArea(editor, E_SWITCH_2)); + assertTrue(fbBot.isFBNamePresendOnEditingArea(editor, E_SWITCH_3)); + assertFalse(fbBot.isFBNamePresendOnEditingArea(editor, E_SWITCH_0)); + assertFalse(fbBot.isFBNamePresendOnEditingArea(editor, E_SWITCH_4)); + + fbBot.deleteFB(editor, E_SWITCH_2); + assertFalse(fbBot.isFBNamePresendOnEditingArea(editor, E_SWITCH_2)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(450, 250)); + assertTrue(fbBot.isFBNamePresendOnEditingArea(editor, E_SWITCH_2)); + + fbBot.deleteFB(editor, E_SWITCH); + fbBot.deleteFB(editor, E_SWITCH_1); + assertFalse(fbBot.isFBNamePresendOnEditingArea(editor, E_SWITCH)); + assertFalse(fbBot.isFBNamePresendOnEditingArea(editor, E_SWITCH_1)); + + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(450, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(250, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(250, 250)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(50, 100)); + assertTrue(fbBot.isFBNamePresendOnEditingArea(editor, E_SWITCH)); + assertTrue(fbBot.isFBNamePresendOnEditingArea(editor, E_SWITCH_1)); + assertTrue(fbBot.isFBNamePresendOnEditingArea(editor, E_SWITCH_4)); + assertTrue(fbBot.isFBNamePresendOnEditingArea(editor, E_SWITCH_5)); } /** diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/SWTBotContextMenuUITests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/contextmenu/SWTBotContextMenuUITests.java similarity index 64% rename from tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/SWTBotContextMenuUITests.java rename to tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/contextmenu/SWTBotContextMenuUITests.java index 8df6c6390d..f28c41a2d9 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/SWTBotContextMenuUITests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/contextmenu/SWTBotContextMenuUITests.java @@ -11,7 +11,7 @@ * Andrea Zoitl - initial API and implementation and/or initial documentation *******************************************************************************/ -package org.eclipse.fordiac.ide.test.ui; +package org.eclipse.fordiac.ide.test.ui.networkediting.contextmenu; import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -21,6 +21,10 @@ import java.util.List; import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.fordiac.ide.test.ui.Abstract4diacUITests; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFB; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotSubapp; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotSystemExplorer; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacFigureCanvas; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; @@ -39,18 +43,19 @@ public class SWTBotContextMenuUITests extends Abstract4diacUITests { * is then created. It is checked if it is empty and displayed correctly in the * SystemExplorer */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void createSubapplicationViaContextMenu() { final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); - editor.clickContextMenu(UITestNamesHelper.NEW_SUBAPPLICATION, 100, 100); final List selectedEditParts = editor.selectedEditParts(); assertEquals(1, selectedEditParts.size()); - assertTrue(isSubappSelected(selectedEditParts, UITestNamesHelper.SUBAPP)); + final SWTBotSubapp subappBot = new SWTBotSubapp(bot); + assertTrue(subappBot.isSubappSelected(selectedEditParts, UITestNamesHelper.SUBAPP)); // check App node and SubApp TreeItem in SystemExplorer tree - assertTrue(isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); - assertTrue(isSubAppNodeInSystemExplorerEmpty()); + final SWTBotSystemExplorer sysExBot = new SWTBotSystemExplorer(bot); + assertTrue(sysExBot.isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); + assertTrue(sysExBot.isSubAppNodeInSystemExplorerEmpty()); } /** @@ -60,7 +65,7 @@ public void createSubapplicationViaContextMenu() { * is then created. It is checked if it is empty and displayed correctly in the * SystemExplorer */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Disabled("until bug in test is found") @Test public void createFBViaContextMenu() { @@ -80,7 +85,8 @@ public void createFBViaContextMenu() { editor.directEditType(UITestNamesHelper.E_CYCLE_FB); bot.sleep(3000); - assertTrue(isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.E_CYCLE_FB)); + final SWTBotSystemExplorer sysExBot = new SWTBotSystemExplorer(bot); + assertTrue(sysExBot.isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.E_CYCLE_FB)); } /** @@ -92,24 +98,26 @@ public void createFBViaContextMenu() { * SystemExplorer tree. Then the subapplication is exited via ContextMenu entry * "Go To Parent" and SystemExplorer Tree is checked again. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void goToParentViaContextMenuEmptySubApp() { final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); editor.clickContextMenu(UITestNamesHelper.NEW_SUBAPPLICATION, 100, 100); // check System Explorer tree if SubApp is present - assertTrue(isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); - assertTrue(isSubAppNodeInSystemExplorerEmpty()); + + final SWTBotSystemExplorer sysExBot = new SWTBotSystemExplorer(bot); + assertTrue(sysExBot.isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); + assertTrue(sysExBot.isSubAppNodeInSystemExplorerEmpty()); goToCompositeInstanceViewer(UITestNamesHelper.SUBAPP); final SWTBot4diacGefEditor editorSubApp = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); assertNotNull(editorSubApp); // check System Explorer tree again after entering subapplication - assertTrue(isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); - assertTrue(isSubAppNodeInSystemExplorerEmpty()); + assertTrue(sysExBot.isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); + assertTrue(sysExBot.isSubAppNodeInSystemExplorerEmpty()); editorSubApp.clickContextMenu(UITestNamesHelper.GO_TO_PARENT, 100, 100); // check System Explorer tree after returning - assertTrue(isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); - assertTrue(isSubAppNodeInSystemExplorerEmpty()); + assertTrue(sysExBot.isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); + assertTrue(sysExBot.isSubAppNodeInSystemExplorerEmpty()); } /** @@ -121,43 +129,49 @@ public void goToParentViaContextMenuEmptySubApp() { * are present in the SystemExplorer tree. Then the SubApp is exited via * ContextMenu entry "Go To Parent" and SystemExplorer Tree is checked again. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void goToParentViaContextMenuSubAppWithFB() { - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(100, 100)); - createSubappWithDragRectangle(50, 50, 400, 400); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(100, 100)); + final SWTBotSubapp subappBot = new SWTBotSubapp(bot); + subappBot.createSubappWithDragRectangle(50, 50, 400, 400); // check System Explorer tree if SubApp is present - assertTrue(isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); - assertTrue(isFBInSubAppOfSystemInSystemExplorer(UITestNamesHelper.E_CYCLE_FB)); + final SWTBotSystemExplorer sysExBot = new SWTBotSystemExplorer(bot); + assertTrue(sysExBot.isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); + assertTrue(sysExBot.isFBInSubAppOfSystemInSystemExplorer(UITestNamesHelper.E_CYCLE_FB)); goToCompositeInstanceViewer(UITestNamesHelper.SUBAPP); final SWTBot4diacGefEditor editorSubApp = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); assertNotNull(editorSubApp); bot.toolbarButton(UITestNamesHelper.TOOLBAR_BUTTON_ZOOM_FIT_PAGE).click(); // check System Explorer tree again after entering subapplication - assertTrue(isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); - assertTrue(isFBInSubAppOfSystemInSystemExplorer(UITestNamesHelper.E_CYCLE_FB)); + assertTrue(sysExBot.isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); + assertTrue(sysExBot.isFBInSubAppOfSystemInSystemExplorer(UITestNamesHelper.E_CYCLE_FB)); editorSubApp.clickContextMenu(UITestNamesHelper.GO_TO_PARENT, 100, 100); // check System Explorer tree after returning - assertTrue(isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); - assertTrue(isFBInSubAppOfSystemInSystemExplorer(UITestNamesHelper.E_CYCLE_FB)); + assertTrue(sysExBot.isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); + assertTrue(sysExBot.isFBInSubAppOfSystemInSystemExplorer(UITestNamesHelper.E_CYCLE_FB)); } - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void goToChildViaContextMenuSubAppWithACompositeFB() { - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); - createSubappWithDragRectangle(50, 50, 300, 300); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); + final SWTBotSubapp subappBot = new SWTBotSubapp(bot); + subappBot.createSubappWithDragRectangle(50, 50, 300, 300); goToCompositeInstanceViewer(UITestNamesHelper.SUBAPP); final SWTBot4diacGefEditor editorSubApp = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); assertNotNull(editorSubApp); bot.toolbarButton(UITestNamesHelper.TOOLBAR_BUTTON_ZOOM_FIT_PAGE).click(); // check bounds of FB - final Rectangle fbBounds = getBoundsOfFB(editorSubApp, UITestNamesHelper.E_N_TABLE_FB); - selectFBWithFBNameInEditor(editorSubApp, UITestNamesHelper.E_N_TABLE_FB); + final Rectangle fbBounds = fbBot.getBoundsOfFB(editorSubApp, UITestNamesHelper.E_N_TABLE_FB); + fbBot.selectFBWithFBNameInEditor(editorSubApp, UITestNamesHelper.E_N_TABLE_FB); editorSubApp.clickContextMenu(UITestNamesHelper.GO_TO_CHILD, fbBounds.x, fbBounds.y); - assertTrue(isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); - assertTrue(isFBInSubAppOfSystemInSystemExplorer(UITestNamesHelper.E_N_TABLE_FB)); + final SWTBotSystemExplorer sysExBot = new SWTBotSystemExplorer(bot); + assertTrue(sysExBot.isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); + assertTrue(sysExBot.isFBInSubAppOfSystemInSystemExplorer(UITestNamesHelper.E_N_TABLE_FB)); } } diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/ErrorMarkerTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/errormarker/ErrorMarkerTests.java similarity index 95% rename from tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/ErrorMarkerTests.java rename to tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/errormarker/ErrorMarkerTests.java index b1ce80dbdf..2b4c218e7a 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/ErrorMarkerTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/errormarker/ErrorMarkerTests.java @@ -10,8 +10,9 @@ * Contributors: * Andrea Zoitl - initial API and implementation and/or initial documentation *******************************************************************************/ -package org.eclipse.fordiac.ide.test.ui; +package org.eclipse.fordiac.ide.test.ui.networkediting.errormarker; +import org.eclipse.fordiac.ide.test.ui.Abstract4diacUITests; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/CompositeInstanceViewerTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/subapp_compsite/CompositeInstanceViewerTests.java similarity index 82% rename from tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/CompositeInstanceViewerTests.java rename to tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/subapp_compsite/CompositeInstanceViewerTests.java index 23c8efe6e8..b4cca644e9 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/CompositeInstanceViewerTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/subapp_compsite/CompositeInstanceViewerTests.java @@ -10,7 +10,7 @@ * Contributors: * Andrea Zoitl - initial API and implementation and/or initial documentation *******************************************************************************/ -package org.eclipse.fordiac.ide.test.ui; +package org.eclipse.fordiac.ide.test.ui.networkediting.subapp_compsite; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -26,7 +26,10 @@ import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.fordiac.ide.fbtypeeditor.network.viewer.CompositeInstanceViewer; import org.eclipse.fordiac.ide.model.ui.editors.AbstractBreadCrumbEditor; +import org.eclipse.fordiac.ide.test.ui.Abstract4diacUITests; import org.eclipse.fordiac.ide.test.ui.helpers.PinNamesHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotConnection; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFB; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefViewer; import org.eclipse.gef.ConnectionEditPart; @@ -49,10 +52,11 @@ public class CompositeInstanceViewerTests extends Abstract4diacUITests { * clicks on it. It is expected that a new breadcrumb tab with the name of the * FB appears and the editor is an instance of CompositeInstanceViewer. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void compositeInstanceViewerAppearsAfterDoubleClickOnFB() { - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(200, 100)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(200, 100)); final SWTBotGefEditor editor = goToCompositeInstanceViewer(UITestNamesHelper.E_N_TABLE_FB); UIThreadRunnable.syncExec(() -> { @@ -78,10 +82,11 @@ public void compositeInstanceViewerAppearsAfterDoubleClickOnFB() { * create a new draw2d.geometry Point, because draw2d.geometry Points are not * compatible with the former. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void compositeInstanceViewerMoveFB() { - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(200, 200)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(200, 200)); goToCompositeInstanceViewer(UITestNamesHelper.E_N_TABLE_FB); final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); @@ -123,10 +128,11 @@ public void compositeInstanceViewerMoveFB() { /** * Checks if it is possible to delete FB in CompositeInstanceViewer */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void compositeInstanceViewerDeleteFB() { - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(200, 200)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(200, 200)); goToCompositeInstanceViewer(UITestNamesHelper.E_N_TABLE_FB); final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); @@ -152,12 +158,13 @@ public void compositeInstanceViewerDeleteFB() { /** * Checks if it is possible to add another FB in CompositeInstanceViewer */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void compositeInstanceViewerAddAnotherFB() { - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(200, 200)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(200, 200)); goToCompositeInstanceViewer(UITestNamesHelper.E_CYCLE_FB); - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(100, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(100, 100)); final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); assertNotNull(editor); assertNotNull(editor.getEditPart(UITestNamesHelper.E_DELAY_FB)); @@ -180,18 +187,20 @@ public void compositeInstanceViewerEditingOfFB() { * The method checks if it is possible to add connections between FB pins in * CompositeInstanceViewer. It is expected that this is not possible. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void compositeInstanceViewerConnectionCanBeAdded() { - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(200, 200)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(200, 200)); goToCompositeInstanceViewer(UITestNamesHelper.E_N_TABLE_FB); - SWTBot4diacGefViewer viewer = createConnection(PinNamesHelper.EO, PinNamesHelper.EI); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + SWTBot4diacGefViewer viewer = connectBot.createConnection(PinNamesHelper.EO, PinNamesHelper.EI); assertThrows(TimeoutException.class, viewer::waitForConnection); - viewer = createConnection(PinNamesHelper.N, PinNamesHelper.CV); + viewer = connectBot.createConnection(PinNamesHelper.N, PinNamesHelper.CV); assertThrows(TimeoutException.class, viewer::waitForConnection); - viewer = createConnection(PinNamesHelper.START, PinNamesHelper.STOP); + viewer = connectBot.createConnection(PinNamesHelper.START, PinNamesHelper.STOP); assertThrows(TimeoutException.class, viewer::waitForConnection); - viewer = createConnection(PinNamesHelper.START, PinNamesHelper.EO0); + viewer = connectBot.createConnection(PinNamesHelper.START, PinNamesHelper.EO0); assertThrows(TimeoutException.class, viewer::waitForConnection); returnToEditingArea(); } @@ -199,15 +208,17 @@ public void compositeInstanceViewerConnectionCanBeAdded() { /** * Checks if it is possible to delete a connection in CompositeInstanceViewer */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void compositeInstanceViewerDeleteConnection() { - dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_N_TABLE_TREE_ITEM, new Point(100, 100)); goToCompositeInstanceViewer(UITestNamesHelper.E_N_TABLE_FB); final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME); final SWTBot4diacGefViewer viewer = (SWTBot4diacGefViewer) editor.getSWTBotGefViewer(); - final ConnectionEditPart connection = findConnection(PinNamesHelper.EO, PinNamesHelper.REQ); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + final ConnectionEditPart connection = connectBot.findConnection(PinNamesHelper.EO, PinNamesHelper.REQ); final PolylineConnection figure = (PolylineConnection) connection.getFigure(); final PointList points = figure.getPoints(); final org.eclipse.draw2d.geometry.Point firstPoint = points.getFirstPoint(); diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/SubappSystemExplorerTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/subapp_compsite/SubappSystemExplorerTests.java similarity index 60% rename from tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/SubappSystemExplorerTests.java rename to tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/subapp_compsite/SubappSystemExplorerTests.java index 1da259c7bd..2aaaf7a17c 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/SubappSystemExplorerTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/subapp_compsite/SubappSystemExplorerTests.java @@ -10,7 +10,7 @@ * Contributors: * Andrea Zoitl - initial API and implementation and/or initial documentation *******************************************************************************/ -package org.eclipse.fordiac.ide.test.ui; +package org.eclipse.fordiac.ide.test.ui.networkediting.subapp_compsite; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -18,6 +18,10 @@ import java.util.List; +import org.eclipse.fordiac.ide.test.ui.Abstract4diacUITests; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFB; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotSubapp; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotSystemExplorer; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; import org.eclipse.swt.graphics.Point; @@ -35,22 +39,25 @@ public class SubappSystemExplorerTests extends Abstract4diacUITests { * the FB is also visible as child of the App node of the System in the * SystemExplorer tree. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void isSubappInSystemExplorerTree() { - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(100, 100)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(100, 100)); final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); - selectFBWithFBNameInEditor(editor, UITestNamesHelper.E_CYCLE_FB); + fbBot.selectFBWithFBNameInEditor(editor, UITestNamesHelper.E_CYCLE_FB); bot.menu(UITestNamesHelper.SOURCE).menu(UITestNamesHelper.NEW_SUBAPPLICATION).click(); final List selectedEditParts = editor.selectedEditParts(); assertEquals(1, selectedEditParts.size()); - assertTrue(isSubappSelected(selectedEditParts, UITestNamesHelper.SUBAPP)); + final SWTBotSubapp subappBot = new SWTBotSubapp(bot); + assertTrue(subappBot.isSubappSelected(selectedEditParts, UITestNamesHelper.SUBAPP)); // checks for SystemExplorer tree - assertTrue(isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); - assertTrue(isFBInSubAppOfSystemInSystemExplorer(UITestNamesHelper.E_CYCLE_FB)); + final SWTBotSystemExplorer sysExBot = new SWTBotSystemExplorer(bot); + assertTrue(sysExBot.isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); + assertTrue(sysExBot.isFBInSubAppOfSystemInSystemExplorer(UITestNamesHelper.E_CYCLE_FB)); } /** @@ -65,28 +72,31 @@ public void isSubappInSystemExplorerTree() { * It is also checked whether E_SWITCH, which does not belong to the SubApp, is * displayed as Application node. */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void isFbAndSubappInSystemExplorerTree() { - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(100, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(300, 100)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(100, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(300, 100)); final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); - selectFBWithFBNameInEditor(editor, UITestNamesHelper.E_CYCLE_FB); + fbBot.selectFBWithFBNameInEditor(editor, UITestNamesHelper.E_CYCLE_FB); bot.menu(UITestNamesHelper.SOURCE).menu(UITestNamesHelper.NEW_SUBAPPLICATION).click(); final List selectedEditParts = editor.selectedEditParts(); assertEquals(1, selectedEditParts.size()); // checks for App node - assertTrue(isSubappSelected(selectedEditParts, UITestNamesHelper.SUBAPP)); - assertTrue(isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); - assertTrue(isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.E_SWITCH_FB)); + final SWTBotSystemExplorer sysExBot = new SWTBotSystemExplorer(bot); + final SWTBotSubapp subappBot = new SWTBotSubapp(bot); + assertTrue(subappBot.isSubappSelected(selectedEditParts, UITestNamesHelper.SUBAPP)); + assertTrue(sysExBot.isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.SUBAPP)); + assertTrue(sysExBot.isElementInApplicationOfSystemInSystemExplorer(UITestNamesHelper.E_SWITCH_FB)); // checks for SubApp node - assertTrue(isFBInSubAppOfSystemInSystemExplorer(UITestNamesHelper.E_CYCLE_FB)); + assertTrue(sysExBot.isFBInSubAppOfSystemInSystemExplorer(UITestNamesHelper.E_CYCLE_FB)); assertThrows(WidgetNotFoundException.class, - () -> isFBInSubAppOfSystemInSystemExplorer(UITestNamesHelper.E_SWITCH_FB)); + () -> sysExBot.isFBInSubAppOfSystemInSystemExplorer(UITestNamesHelper.E_SWITCH_FB)); } } diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/SubapplicationTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/subapp_compsite/SubapplicationTests.java similarity index 63% rename from tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/SubapplicationTests.java rename to tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/subapp_compsite/SubapplicationTests.java index 584cac650c..5a40131c80 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/SubapplicationTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/networkediting/subapp_compsite/SubapplicationTests.java @@ -10,7 +10,7 @@ * Contributors: * Andrea Zoitl - initial API and implementation and/or initial documentation *******************************************************************************/ -package org.eclipse.fordiac.ide.test.ui; +package org.eclipse.fordiac.ide.test.ui.networkediting.subapp_compsite; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -21,7 +21,11 @@ import java.util.List; import org.eclipse.fordiac.ide.model.ui.editors.HandlerHelper; +import org.eclipse.fordiac.ide.test.ui.Abstract4diacUITests; import org.eclipse.fordiac.ide.test.ui.helpers.PinNamesHelper; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotConnection; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFB; +import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotSubapp; import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor; import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefViewer; @@ -29,7 +33,6 @@ import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; public class SubapplicationTests extends Abstract4diacUITests { @@ -39,16 +42,15 @@ public class SubapplicationTests extends Abstract4diacUITests { * Application editor breadcrumb. */ @SuppressWarnings("static-method") - @Disabled("until bug fix") @Test public void createEmptySubappViaMenu() { final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); bot.menu(UITestNamesHelper.SOURCE).menu(UITestNamesHelper.NEW_SUBAPPLICATION).click(); - editor.drag(10, 10, 500, 500); - assertDoesNotThrow(() -> editor.waitForSelectedFBEditPart()); + editor.drag(50, 50, 500, 500); final List selectedEditParts = editor.selectedEditParts(); assertEquals(1, selectedEditParts.size()); - assertTrue(isSubappSelected(selectedEditParts, UITestNamesHelper.SUBAPP)); + final SWTBotSubapp subappBot = new SWTBotSubapp(bot); + assertTrue(subappBot.isSubappSelected(selectedEditParts, UITestNamesHelper.SUBAPP)); } /** @@ -62,24 +64,26 @@ public void createEmptySubappViaMenu() { @SuppressWarnings("static-method") @Test public void createSubappViaMenu() { - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(100, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, new Point(300, 100)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(100, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, new Point(300, 100)); final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); - // drag rectangle over to FB, therefore FB should be selected - editor.drag(50, 50, 400, 400); + // drag rectangle over the FBs, therefore FBs should be selected + editor.drag(80, 80, 400, 400); assertDoesNotThrow(() -> editor.waitForSelectedFBEditPart()); List selectedEditParts = editor.selectedEditParts(); assertFalse(selectedEditParts.isEmpty()); assertEquals(2, selectedEditParts.size()); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_SR_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_SR_FB)); bot.menu(UITestNamesHelper.SOURCE).menu(UITestNamesHelper.NEW_SUBAPPLICATION).click(); // renew list of selectedEditParts and then check if SubApp was created selectedEditParts = editor.selectedEditParts(); assertEquals(1, selectedEditParts.size()); - assertTrue(isSubappSelected(selectedEditParts, UITestNamesHelper.SUBAPP)); + final SWTBotSubapp subappBot = new SWTBotSubapp(bot); + assertTrue(subappBot.isSubappSelected(selectedEditParts, UITestNamesHelper.SUBAPP)); } /** @@ -90,14 +94,16 @@ public void createSubappViaMenu() { * are created and then a rectangle is drawn over the FBs. Then a subapplication * is created via menu entry "Source" -> "New subapplication" */ - @SuppressWarnings("static-method") + @SuppressWarnings({ "static-method", "static-access" }) @Test public void createSubappViaMenuWithConnectionBetweenFBs() { - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(100, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, new Point(300, 100)); - assertNotNull(createConnection(PinNamesHelper.EO0, PinNamesHelper.S)); - assertNotNull(createConnection(PinNamesHelper.EO1, PinNamesHelper.R)); - assertNotNull(createConnection(PinNamesHelper.Q, PinNamesHelper.G)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(100, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, new Point(300, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + assertNotNull(connectBot.createConnection(PinNamesHelper.EO0, PinNamesHelper.S)); + assertNotNull(connectBot.createConnection(PinNamesHelper.EO1, PinNamesHelper.R)); + assertNotNull(connectBot.createConnection(PinNamesHelper.Q, PinNamesHelper.G)); // drag rectangle over to FB, therefore FB should be selected final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); @@ -109,17 +115,18 @@ public void createSubappViaMenuWithConnectionBetweenFBs() { // expected 5 selected EditParts (2 GefEditPart for the FBs and // 3 GefConnectionEditPars for the connections assertEquals(5, selectedEditParts.size()); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_SR_FB)); - assertTrue(checkIfConnectionCanBeFound(PinNamesHelper.EO0, PinNamesHelper.S)); - assertTrue(checkIfConnectionCanBeFound(PinNamesHelper.EO1, PinNamesHelper.R)); - assertTrue(checkIfConnectionCanBeFound(PinNamesHelper.Q, PinNamesHelper.G)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_SR_FB)); + assertTrue(connectBot.checkIfConnectionCanBeFound(PinNamesHelper.EO0, PinNamesHelper.S)); + assertTrue(connectBot.checkIfConnectionCanBeFound(PinNamesHelper.EO1, PinNamesHelper.R)); + assertTrue(connectBot.checkIfConnectionCanBeFound(PinNamesHelper.Q, PinNamesHelper.G)); bot.menu(UITestNamesHelper.SOURCE).menu(UITestNamesHelper.NEW_SUBAPPLICATION).click(); // renew list of selectedEditParts and then check if SubApp was created selectedEditParts = editor.selectedEditParts(); assertEquals(1, selectedEditParts.size()); - assertTrue(isSubappSelected(selectedEditParts, UITestNamesHelper.SUBAPP)); + final SWTBotSubapp subappBot = new SWTBotSubapp(bot); + assertTrue(subappBot.isSubappSelected(selectedEditParts, UITestNamesHelper.SUBAPP)); } /** @@ -134,10 +141,12 @@ public void createSubappViaMenuWithConnectionBetweenFBs() { @SuppressWarnings("static-method") @Test public void createSubappViaMenuWithExistingConnectionOutsideSubapp() { - dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(100, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(300, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, new Point(500, 100)); - assertNotNull(createConnection(PinNamesHelper.EO, PinNamesHelper.EI)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_CYCLE_TREE_ITEM, new Point(100, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(300, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, new Point(500, 100)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + assertNotNull(connectBot.createConnection(PinNamesHelper.EO, PinNamesHelper.EI)); // drag rectangle over to FBs E_SWITCH and E_SR, therefore FBs should be // selected @@ -147,17 +156,18 @@ public void createSubappViaMenuWithExistingConnectionOutsideSubapp() { List selectedEditParts = editor.selectedEditParts(); assertFalse(selectedEditParts.isEmpty()); assertEquals(2, selectedEditParts.size()); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); - assertTrue(isFbSelected(selectedEditParts, UITestNamesHelper.E_SR_FB)); - assertFalse(isFbSelected(selectedEditParts, UITestNamesHelper.E_CYCLE_TREE_ITEM)); - assertTrue(checkIfConnectionCanBeFound(PinNamesHelper.EO, PinNamesHelper.EI)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_SWITCH_FB)); + assertTrue(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_SR_FB)); + assertFalse(fbBot.isFbSelected(selectedEditParts, UITestNamesHelper.E_CYCLE_TREE_ITEM)); + assertTrue(connectBot.checkIfConnectionCanBeFound(PinNamesHelper.EO, PinNamesHelper.EI)); bot.menu(UITestNamesHelper.SOURCE).menu(UITestNamesHelper.NEW_SUBAPPLICATION).click(); // renew list of selectedEditParts and then check if SubApp was created selectedEditParts = editor.selectedEditParts(); assertEquals(1, selectedEditParts.size()); - assertTrue(isSubappSelected(selectedEditParts, UITestNamesHelper.SUBAPP)); - assertTrue(checkIfConnectionCanBeFound(PinNamesHelper.EO, PinNamesHelper.EO)); + final SWTBotSubapp subappBot = new SWTBotSubapp(bot); + assertTrue(subappBot.isSubappSelected(selectedEditParts, UITestNamesHelper.SUBAPP)); + assertTrue(connectBot.checkIfConnectionCanBeFound(PinNamesHelper.EO, PinNamesHelper.EO)); } /** @@ -170,8 +180,9 @@ public void createSubappViaMenuWithExistingConnectionOutsideSubapp() { @SuppressWarnings("static-method") @Test public void createSubappViaMenuThenCreatingConnection() { - dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(100, 100)); - dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, new Point(300, 100)); + final SWTBotFB fbBot = new SWTBotFB(bot); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SWITCH_TREE_ITEM, new Point(100, 100)); + fbBot.dragAndDropEventsFB(UITestNamesHelper.E_SR_TREE_ITEM, new Point(300, 100)); final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME); editor.drag(50, 50, 400, 400); @@ -188,9 +199,10 @@ public void createSubappViaMenuThenCreatingConnection() { // syncExec() is needed to update selection of UI and therefore it needs to run // in UI thread. Without this, the connections are not created correctly UIThreadRunnable.syncExec(() -> HandlerHelper.selectEditPart(viewer.getGraphicalViewer(), editPart.part())); - assertNotNull(createConnection(PinNamesHelper.EO0, PinNamesHelper.S)); - assertNotNull(createConnection(PinNamesHelper.EO1, PinNamesHelper.R)); - assertNotNull(createConnection(PinNamesHelper.Q, PinNamesHelper.G)); + final SWTBotConnection connectBot = new SWTBotConnection(bot); + assertNotNull(connectBot.createConnection(PinNamesHelper.EO0, PinNamesHelper.S)); + assertNotNull(connectBot.createConnection(PinNamesHelper.EO1, PinNamesHelper.R)); + assertNotNull(connectBot.createConnection(PinNamesHelper.Q, PinNamesHelper.G)); } }