Skip to content

Commit

Permalink
NatWithEditorBehavoirTests test are running again eclipse-4diac#377
Browse files Browse the repository at this point in the history
This is not a stand-alone commit, the tests of class
NatTableWithEditorBehaviorTests and derived classes are now adapted to
the new structure. The remaining SWTBot tests will follow.

Addresses eclipse-4diac#377
  • Loading branch information
Andrearium committed Sep 16, 2024
1 parent cd63b41 commit a6f51b8
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import org.eclipse.fordiac.ide.test.ui.helpers.UITestPinHelper;
import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotPropertySheet;
import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFBType;
import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotNatTable;
import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotPropertySheet;
import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper;
import org.eclipse.fordiac.ide.test.ui.helpers.UITestPinHelper;
import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor;
import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacNatTable;
import org.eclipse.nebula.widgets.nattable.NatTable;
Expand All @@ -33,9 +33,9 @@ public class EventInOutputsTabTests extends NatTableWithEditorBehaviorTests {
@Override
@BeforeEach
public void operationsInitialization() {
TESTVAR1 = UITestPinHelper.EI1;
TESTVAR2 = UITestPinHelper.EI2;
TESTVAR3 = UITestPinHelper.EI3;
testvar1 = UITestPinHelper.EI1;
testvar2 = UITestPinHelper.EI2;
testvar3 = UITestPinHelper.EI3;
final SWTBotFBType fbTypeBot = new SWTBotFBType(bot);
fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2,
UITestNamesHelper.ADAPTER);
Expand All @@ -46,21 +46,21 @@ public void operationsInitialization() {
bot.editorByTitle(UITestNamesHelper.FBT_TEST_PROJECT2).show();
SWTBotPropertySheet.selectPropertyTabItem(UITestNamesHelper.EVENT_IN_AND_OUTPUTS, propertiesBot);
natTable = propertiesBot.widget(WidgetMatcherFactory.widgetOfType(NatTable.class), 0);
natTableBot = new SWTBot4diacNatTable(natTable);
swt4diacNatTable = new SWTBot4diacNatTable(natTable);
editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.FBT_TEST_PROJECT2);
assertNotNull(editor);
SWTBotNatTable.createNewVariableInDataTypeEditor(natTableBot);
new SWTBotNatTable(bot, swt4diacNatTable).createNewVariableInDataTypeEditor();
}

@Override
@Test
public void changeDataTypeOfVariable() {
natTableBot.doubleclick(1, 2);
natTableBot.setCellDataValueByPosition(1, 2, UITestNamesHelper.TESTVAR);
natTableBot.doubleclick(1, 2);
swt4diacNatTable.doubleclick(1, 2);
swt4diacNatTable.setCellDataValueByPosition(1, 2, UITestNamesHelper.TESTVAR);
swt4diacNatTable.doubleclick(1, 2);

// Initial value will successfully changed with error
assertEquals(natTableBot.getCellDataValueByPosition(1, 2), UITestNamesHelper.EVENT);
assertEquals(swt4diacNatTable.getCellDataValueByPosition(1, 2), UITestNamesHelper.EVENT);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
import org.junit.jupiter.api.Test;

public abstract class NatTableWithEditorBehaviorTests extends Abstract4diacUITests {
protected static SWTBot4diacNatTable natTableBot;
protected static NatTable natTable;
protected static SWTBot4diacGefEditor editor;
protected SWTBot4diacNatTable swt4diacNatTable;
protected NatTable natTable;
protected SWTBot4diacGefEditor editor;

protected static String TESTVAR1 = "TESTVAR1"; //$NON-NLS-1$
protected static String TESTVAR2 = "TESTVAR2"; //$NON-NLS-1$
protected static String TESTVAR3 = "TESTVAR3"; //$NON-NLS-1$
protected String testvar1 = "TESTVAR1"; //$NON-NLS-1$
protected String testvar2 = "TESTVAR2"; //$NON-NLS-1$
protected String testvar3 = "TESTVAR3"; //$NON-NLS-1$

/**
* Initializes the environment for testing operations on the DataType Editor
Expand All @@ -45,7 +45,6 @@ public abstract class NatTableWithEditorBehaviorTests extends Abstract4diacUITes
* its visibility in the system explorer, opens the project in the editor, and
* prepares the NatTable for testing by creating a new variable in the table.
*/
@SuppressWarnings("static-method")
@BeforeEach
public void operationsInitialization() {
final SWTBotFBType fbTypeBot = new SWTBotFBType(bot);
Expand All @@ -54,8 +53,8 @@ public void operationsInitialization() {
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);
SWTBotNatTable.createNewVariableInDataTypeEditor(natTableBot);
swt4diacNatTable = new SWTBot4diacNatTable(natTable);
new SWTBotNatTable(bot, swt4diacNatTable).createNewVariableInDataTypeEditor();
}

/**
Expand All @@ -77,11 +76,10 @@ public void resetEnvironment() {
* This method verifies that a new event can be created successfully by checking
* the presence of the new variable in the editor.
*/
@SuppressWarnings("static-method")
@Test
public void createEvent() {
SWTBotNatTable.createNewVariableInDataTypeEditor(natTableBot);
assertNotNull(editor.getEditPart(TESTVAR1));
new SWTBotNatTable(bot, swt4diacNatTable).createNewVariableInDataTypeEditor();
assertNotNull(editor.getEditPart(testvar1));
}

/**
Expand All @@ -90,11 +88,10 @@ public void createEvent() {
* This method verifies that an event can be removed successfully by checking
* the absence of the variable in the editor after deletion.
*/
@SuppressWarnings("static-method")
@Test
public void removeEvent() {
SWTBotNatTable.deleteVariable(natTableBot, 3);
assertNull(editor.getEditPart(TESTVAR1));
new SWTBotNatTable(bot, swt4diacNatTable).deleteVariable(3);
assertNull(editor.getEditPart(testvar1));
}

/**
Expand All @@ -104,12 +101,11 @@ public void removeEvent() {
* checks that the old name is no longer present in the editor, while the new
* name is.
*/
@SuppressWarnings("static-method")
@Test
public void changeEventName() {
assertNotNull(editor.getEditPart(TESTVAR1));
SWTBotNatTable.changeCellValueInNatTbale(natTableBot, UITestNamesHelper.TESTVAR, 3, 1);
assertNull(editor.getEditPart(TESTVAR1));
assertNotNull(editor.getEditPart(testvar1));
new SWTBotNatTable(bot, swt4diacNatTable).changeCellValueInNatTbale(UITestNamesHelper.TESTVAR, 3, 1);
assertNull(editor.getEditPart(testvar1));
assertNotNull(editor.getEditPart(UITestNamesHelper.TESTVAR));
}

Expand All @@ -119,12 +115,11 @@ public void changeEventName() {
* This method verifies that the event name can be changed using the rename
* button tool and checks the presence of the new name in the editor.
*/
@SuppressWarnings("static-method")
@Test
public void changeEventNameFromRenameButtom() {
assertNotNull(editor.getEditPart(TESTVAR1));
SWTBotNatTable.changeVariableNameWithButtonTool(natTableBot, 3, UITestNamesHelper.TESTVAR);
assertNull(editor.getEditPart(TESTVAR1));
assertNotNull(editor.getEditPart(testvar1));
new SWTBotNatTable(bot, swt4diacNatTable).changeVariableNameWithButtonTool(3, UITestNamesHelper.TESTVAR);
assertNull(editor.getEditPart(testvar1));
assertNotNull(editor.getEditPart(UITestNamesHelper.TESTVAR));
}

Expand All @@ -137,7 +132,7 @@ public void changeEventNameFromRenameButtom() {
@SuppressWarnings("static-method")
@Test
public void changeDataTypeOfVariable() {
SWTBotNatTable.changeDataType(natTableBot, 1, UITestNamesHelper.INT_SMALL);
new SWTBotNatTable(bot, swt4diacNatTable).changeDataType(1, UITestNamesHelper.INT_SMALL);
}

/**
Expand All @@ -149,7 +144,7 @@ public void changeDataTypeOfVariable() {
@SuppressWarnings("static-method")
@Test
public void tryToSetInValidDataType() {
SWTBotNatTable.setInvalidDataType(natTableBot, 1, 2, UITestNamesHelper.TESTVAR);
new SWTBotNatTable(bot, swt4diacNatTable).setInvalidDataType(1, 2, UITestNamesHelper.TESTVAR);
}

/**
Expand All @@ -158,12 +153,11 @@ public void tryToSetInValidDataType() {
* This method verifies the ability to change the comment associated with an
* event and checks for the expected changes in the editor.
*/
@SuppressWarnings("static-method")
@Test
public void changeEventComment() {
assertNotNull(editor.getEditPart(TESTVAR1));
assertNotNull(editor.getEditPart(testvar1));
assertNull(editor.getEditPart(UITestNamesHelper.TESTVAR));
SWTBotNatTable.changeCellValueInNatTbale(natTableBot, UITestNamesHelper.TEST_COMMENT, 3, 3);
new SWTBotNatTable(bot, swt4diacNatTable).changeCellValueInNatTbale(UITestNamesHelper.TEST_COMMENT, 3, 3);
}

/**
Expand All @@ -175,10 +169,11 @@ public void changeEventComment() {
@SuppressWarnings("static-method")
@Test
public void moveEventUpDown() {
SWTBotNatTable.createNewVariableInDataTypeEditor(natTableBot);
SWTBotNatTable.createNewVariableInDataTypeEditor(natTableBot);
SWTBotNatTable.moveElementUp(natTableBot, 5);
SWTBotNatTable.moveElementDown(natTableBot, 3);
final SWTBotNatTable swtBotNatTable = new SWTBotNatTable(bot, swt4diacNatTable);
swtBotNatTable.createNewVariableInDataTypeEditor();
swtBotNatTable.createNewVariableInDataTypeEditor();
swtBotNatTable.moveElementUp(5);
swtBotNatTable.moveElementDown(3);
}

/**
Expand All @@ -187,15 +182,15 @@ public void moveEventUpDown() {
* This method checks whether the editor prevents changing an event name to a
* name that already exists in the DataType Editor Table.
*/
@SuppressWarnings("static-method")
@Test
public void tryToChangeEventNameWithExistingName() {
SWTBotNatTable.createNewVariableInDataTypeEditor(natTableBot);
assertNotNull(editor.getEditPart(TESTVAR1));
assertNotNull(editor.getEditPart(TESTVAR2));
SWTBotNatTable.changeNameWithExistingName(natTableBot, 4, TESTVAR1, TESTVAR2);
assertNotNull(editor.getEditPart(TESTVAR1));
assertNotNull(editor.getEditPart(TESTVAR2));
final SWTBotNatTable swtBotNatTable = new SWTBotNatTable(bot, swt4diacNatTable);
swtBotNatTable.createNewVariableInDataTypeEditor();
assertNotNull(editor.getEditPart(testvar1));
assertNotNull(editor.getEditPart(testvar2));
swtBotNatTable.changeNameWithExistingName(4, testvar1, testvar2);
assertNotNull(editor.getEditPart(testvar1));
assertNotNull(editor.getEditPart(testvar2));
}

/**
Expand All @@ -204,14 +199,14 @@ public void tryToChangeEventNameWithExistingName() {
* This method verifies the editor's response when an invalid name is assigned
* to an event, ensuring that invalid names are not accepted.
*/
@SuppressWarnings("static-method")
@Test
public void tryToSetInvalidName() {
SWTBotNatTable.createNewVariableInDataTypeEditor(natTableBot);
assertNotNull(editor.getEditPart(TESTVAR1));
SWTBotNatTable.setInvalidName(natTableBot, 3, UITestNamesHelper.IF, TESTVAR1);
final SWTBotNatTable swtBotNatTable = new SWTBotNatTable(bot, swt4diacNatTable);
swtBotNatTable.createNewVariableInDataTypeEditor();
assertNotNull(editor.getEditPart(testvar1));
swtBotNatTable.setInvalidName(3, UITestNamesHelper.IF, testvar1);
assertNull(editor.getEditPart(UITestNamesHelper.IF));
assertNotNull(editor.getEditPart(TESTVAR2));
assertNotNull(editor.getEditPart(testvar2));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
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.helpers.UITestPinHelper;
import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotPropertySheet;
import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotFBType;
import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotNatTable;
import org.eclipse.fordiac.ide.test.ui.helpers.SWTBotPropertySheet;
import org.eclipse.fordiac.ide.test.ui.helpers.UITestNamesHelper;
import org.eclipse.fordiac.ide.test.ui.helpers.UITestPinHelper;
import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacGefEditor;
import org.eclipse.fordiac.ide.test.ui.swtbot.SWTBot4diacNatTable;
import org.eclipse.nebula.widgets.nattable.NatTable;
Expand All @@ -34,9 +34,9 @@ public class VarInAndOutputsTabTests extends NatTableWithEditorBehaviorTests {
@Override
@BeforeEach
public void operationsInitialization() {
TESTVAR1 = UITestPinHelper.DI1;
TESTVAR2 = UITestPinHelper.DI2;
TESTVAR3 = UITestPinHelper.DI3;
testvar1 = UITestPinHelper.DI1;
testvar2 = UITestPinHelper.DI2;
testvar3 = UITestPinHelper.DI3;
final SWTBotFBType fbTypeBot = new SWTBotFBType(bot);
fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2,
UITestNamesHelper.ADAPTER);
Expand All @@ -47,10 +47,10 @@ public void operationsInitialization() {
bot.editorByTitle(UITestNamesHelper.FBT_TEST_PROJECT2).show();
SWTBotPropertySheet.selectPropertyTabItem(UITestNamesHelper.VAR_IN_AND_OUTPUTS, propertiesBot);
natTable = propertiesBot.widget(WidgetMatcherFactory.widgetOfType(NatTable.class), 0);
natTableBot = new SWTBot4diacNatTable(natTable);
swt4diacNatTable = new SWTBot4diacNatTable(natTable);
editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.FBT_TEST_PROJECT2);
assertNotNull(editor);
SWTBotNatTable.createNewVariableInDataTypeEditor(natTableBot);
new SWTBotNatTable(bot, swt4diacNatTable).createNewVariableInDataTypeEditor();
}

/**
Expand All @@ -59,11 +59,11 @@ public void operationsInitialization() {
* This test checks whether the initial value of a variable can be changed, and
* asserts that the new value is correctly assigned.
*/
@SuppressWarnings("static-method")
@Test
public void changeInitialValueOfVariable() {
SWTBotNatTable.changeCellValueInNatTbale(natTableBot, UITestNamesHelper.TRUE, 1, 4);
SWTBotNatTable.changeCellValueInNatTbale(natTableBot, "1", 1, 4); //$NON-NLS-1$
final SWTBotNatTable swtBotNatTable = new SWTBotNatTable(bot, swt4diacNatTable);
swtBotNatTable.changeCellValueInNatTbale(UITestNamesHelper.TRUE, 1, 4);
swtBotNatTable.changeCellValueInNatTbale("1", 1, 4); //$NON-NLS-1$
}

/**
Expand All @@ -73,10 +73,9 @@ public void changeInitialValueOfVariable() {
* verifies whether the assignment is successful and what impact it has on the
* editor.
*/
@SuppressWarnings("static-method")
@Test
public void tryToSetInValidInitialValue() {
SWTBotNatTable.setInvalidDataType(natTableBot, 1, 4, UITestNamesHelper.TESTVAR);
new SWTBotNatTable(bot, swt4diacNatTable).setInvalidDataType(1, 4, UITestNamesHelper.TESTVAR);
}

/**
Expand All @@ -85,12 +84,11 @@ public void tryToSetInValidInitialValue() {
* This test verifies the toggling behavior of a variable's configuration
* setting, ensuring that the value switches between "true" and "false".
*/
@SuppressWarnings("static-method")
@Test
public void toggleVarConfiguration() {
assertEquals(natTableBot.getCellDataValueByPosition(2, 6), UITestNamesHelper.FALSE_SMALL);
natTableBot.click(2, 6);
assertEquals(natTableBot.getCellDataValueByPosition(2, 6), UITestNamesHelper.TRUE_SMALL);
assertEquals(swt4diacNatTable.getCellDataValueByPosition(2, 6), UITestNamesHelper.FALSE_SMALL);
swt4diacNatTable.click(2, 6);
assertEquals(swt4diacNatTable.getCellDataValueByPosition(2, 6), UITestNamesHelper.TRUE_SMALL);
}

/**
Expand All @@ -99,12 +97,11 @@ public void toggleVarConfiguration() {
* This test checks the toggling behavior of a variable's visibility setting,
* confirming that the value alternates between "true" and "false".
*/
@SuppressWarnings("static-method")
@Test
public void toggleVarVisibility() {
assertEquals(natTableBot.getCellDataValueByPosition(2, 5), UITestNamesHelper.TRUE_SMALL);
natTableBot.click(2, 5);
assertEquals(natTableBot.getCellDataValueByPosition(2, 5), UITestNamesHelper.FALSE_SMALL);
assertEquals(swt4diacNatTable.getCellDataValueByPosition(2, 5), UITestNamesHelper.TRUE_SMALL);
swt4diacNatTable.click(2, 5);
assertEquals(swt4diacNatTable.getCellDataValueByPosition(2, 5), UITestNamesHelper.FALSE_SMALL);
}

/**
Expand All @@ -114,9 +111,8 @@ public void toggleVarVisibility() {
* successfully and checks that the new retain tag value is correctly set in the
* NatTable.
*/
@SuppressWarnings("static-method")
@Test
public void changeRetainTag() {
SWTBotNatTable.setRetainValue(natTableBot, 1, 7, RetainTag.RETAIN);
new SWTBotNatTable(bot, swt4diacNatTable).setRetainValue(1, 7, RetainTag.RETAIN);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class SWTBotNatTable {
private final SWT4diacGefBot bot;
private final SWTBot4diacNatTable natTable;

@SuppressWarnings("static-access")
public SWTBotNatTable(final SWT4diacGefBot bot, final SWTBot4diacNatTable natTableBot) {
this.bot = bot;
this.natTable = natTableBot;
Expand Down

0 comments on commit a6f51b8

Please sign in to comment.