Skip to content

Commit

Permalink
SWTBot UI NatTable tests have been migrated to the new UI test archit…
Browse files Browse the repository at this point in the history
…ecture. (#499)

* Renamed helper class NatTableHelper for SWTBot UI Tests #377

Rename class NatTabletHelper to SWTBotNatTable to be consistent
with the other supporting Bot classes for UI tests.

Addresses #377

* Restructured supporting Bot class SWTNatTable #377

This is not a stand-alone commit, the related tests will be adapted to
the new structure in the next commit and therefore only be executable
again at that point in future.

- The class SWTNatTable no longer derives from Abstract4diacUITests
- The class now has a constructor with parameters
SWT4diacGefBot and SWTBot4diacNatTable and corresponding fields.
- The methods are no longer static and the Bot parameters was removed.

Addresses #377

* NatWithEditorBehavoirTests test are running again #377

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 #377

* Simplified initialization of tests from NatWithEditorBehavoirTests #377

For better readability and maintainability, the test variables from the
method operationsInitialzation() with Annotation @beforeeach have been
moved to a constructor.

Addresses #377

* NatWithoutEditorBehavoirTests test are running again #377

The tests of class NatTableWithoutEditorBehaviorTests and tests of
derived classes are now adapted to the new test structure.

Addresses #377

* Simplified tests from NatWithoutEditorBehavoirTests #377

For better readability and maintainability, the test variables from the
method operationsInitialzation() with Annotation @beforeeach have been
moved to a constructor.

Addresses #377
  • Loading branch information
Andrearium authored Sep 19, 2024
1 parent 3ddb449 commit 42fed24
Show file tree
Hide file tree
Showing 11 changed files with 426 additions and 401 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Prashantkumar Khatri
* 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
Expand All @@ -9,12 +9,14 @@
*
* Contributors:
* Prashantkumar Khatri - initial API and implementation and/or initial documentation
* Andrea Zoitl - Creation of a fluid API design for UI SWTBot testing
*******************************************************************************/
package org.eclipse.fordiac.ide.test.ui.fbtype;

import static org.junit.jupiter.api.Assertions.assertNotNull;

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.swtbot.SWTBot4diacNatTable;
Expand All @@ -25,6 +27,11 @@

// Have to look into the table as this has so much different behavior
public class AttributesTabTests extends NatTableWithoutEditorBehaviorTests {

public AttributesTabTests() {
super(UITestNamesHelper.ATTRIBUTE1, UITestNamesHelper.ATTRIBUTE2, UITestNamesHelper.ATTRIBUTE3);
}

/**
* Performs necessary tasks to make environment for testing the operations on
* DataType Editor Table.
Expand All @@ -36,9 +43,6 @@ public class AttributesTabTests extends NatTableWithoutEditorBehaviorTests {
@Override
@BeforeEach
public void operationsInitialization() {
TESTVAR1 = UITestNamesHelper.ATTRIBUTE1;
TESTVAR2 = UITestNamesHelper.ATTRIBUTE2;
TESTVAR3 = UITestNamesHelper.ATTRIBUTE3;
final SWTBotFBType fbTypeBot = new SWTBotFBType(bot);
fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2,
UITestNamesHelper.TEMPLATEBASIC);
Expand All @@ -49,8 +53,8 @@ public void operationsInitialization() {
bot.editorByTitle(UITestNamesHelper.FBT_TEST_PROJECT2).show();
SWTBotPropertySheet.selectPropertyTabItem(UITestNamesHelper.ATTRIBUTES, propertiesBot);
natTable = propertiesBot.widget(WidgetMatcherFactory.widgetOfType(NatTable.class), 0);
natTableBot = new SWTBot4diacNatTable(natTable);
NatTableHelper.createNewVariableInDataTypeEditor(natTableBot);
swt4diacNatTable = new SWTBot4diacNatTable(natTable);
new SWTBotNatTable(bot, swt4diacNatTable).createNewVariableInDataTypeEditor();
}

@Override
Expand All @@ -61,13 +65,13 @@ public void changeVariableNameWithButton() {
@Override
public void tryToSetInValidName() {
// Here Name column has same behavior as Data Type column or Invalid value
NatTableHelper.setInvalidDataType(natTableBot, 1, 1, UITestNamesHelper.IF);
new SWTBotNatTable(bot, swt4diacNatTable).setInvalidDataType(1, 1, UITestNamesHelper.IF);
}

@Override
public void tryToChangeNameOfVariableWithExistingName() {
// Here Name column has same behavior as Data Type column or Invalid value
NatTableHelper.setInvalidDataType(natTableBot, 1, 1, UITestNamesHelper.IF);
new SWTBotNatTable(bot, swt4diacNatTable).setInvalidDataType(1, 1, UITestNamesHelper.IF);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Prashantkumar Khatri
* 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
Expand All @@ -9,13 +9,15 @@
*
* Contributors:
* Prashantkumar Khatri - initial API and implementation and/or initial documentation
* Andrea Zoitl - Creation of a fluid API design for UI SWTBot testing
*******************************************************************************/
package org.eclipse.fordiac.ide.test.ui.fbtype;

import static org.junit.jupiter.api.Assertions.assertNotNull;

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.swtbot.SWTBot4diacNatTable;
import org.eclipse.nebula.widgets.nattable.NatTable;
Expand All @@ -25,12 +27,14 @@

public class ConstantsTabTests extends NatTableWithoutEditorBehaviorTests {

public ConstantsTabTests() {
super(UITestNamesHelper.INTERNALCONSTVAR1, UITestNamesHelper.INTERNALCONSTVAR2,
UITestNamesHelper.INTERNALCONSTVAR3);
}

@Override
@BeforeEach
public void operationsInitialization() {
TESTVAR1 = UITestNamesHelper.INTERNALCONSTVAR1;
TESTVAR2 = UITestNamesHelper.INTERNALCONSTVAR2;
TESTVAR3 = UITestNamesHelper.INTERNALCONSTVAR3;
final SWTBotFBType fbTypeBot = new SWTBotFBType(bot);
fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2,
UITestNamesHelper.TEMPLATEBASIC);
Expand All @@ -41,7 +45,7 @@ public void operationsInitialization() {
bot.editorByTitle(UITestNamesHelper.FBT_TEST_PROJECT2).show();
SWTBotPropertySheet.selectPropertyTabItem(UITestNamesHelper.CONSTANTS, propertiesBot);
natTable = propertiesBot.widget(WidgetMatcherFactory.widgetOfType(NatTable.class), 0);
natTableBot = new SWTBot4diacNatTable(natTable);
NatTableHelper.createNewVariableInDataTypeEditor(natTableBot);
swt4diacNatTable = new SWTBot4diacNatTable(natTable);
new SWTBotNatTable(bot, swt4diacNatTable).createNewVariableInDataTypeEditor();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Prashantkumar Khatri
* 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
Expand All @@ -10,10 +10,12 @@
* Contributors:
*
* Prashantkumar Khatri - initial API and implementation and/or initial documentation
* Andrea Zoitl - Creation of a fluid API design for UI SWTBot testing
*******************************************************************************/
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.SWTBotNatTable;
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;
Expand All @@ -23,12 +25,13 @@

public class DataTypeEditorTests extends NatTableWithoutEditorBehaviorTests {

public DataTypeEditorTests() {
super(UITestNamesHelper.VAR1, UITestNamesHelper.VAR2, UITestNamesHelper.VAR3);
}

@Override
@BeforeEach
public void operationsInitialization() {
TESTVAR1 = UITestNamesHelper.VAR1;
TESTVAR2 = UITestNamesHelper.VAR2;
TESTVAR3 = UITestNamesHelper.VAR3;

final SWTBotFBType fbTypeBot = new SWTBotFBType(bot);
fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2,
Expand All @@ -37,7 +40,7 @@ public void operationsInitialization() {

final Composite tableComposite = (Composite) bot.editorByTitle(UITestNamesHelper.FBT_TEST_PROJECT2).getWidget();
natTable = bot.widget(WidgetMatcherFactory.widgetOfType(NatTable.class), tableComposite);
natTableBot = new SWTBot4diacNatTable(natTable);
NatTableHelper.createNewVariableInDataTypeEditor(natTableBot);
swt4diacNatTable = new SWTBot4diacNatTable(natTable);
new SWTBotNatTable(bot, swt4diacNatTable).createNewVariableInDataTypeEditor();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Prashantkumar Khatri
* 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
Expand All @@ -9,16 +9,18 @@
*
* Contributors:
* Prashantkumar Khatri - initial API and implementation and/or initial documentation
* Andrea Zoitl - Creation of a fluid API design for UI SWTBot testing
*******************************************************************************/
package org.eclipse.fordiac.ide.test.ui.fbtype;

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 @@ -29,12 +31,13 @@

public class EventInOutputsTabTests extends NatTableWithEditorBehaviorTests {

public EventInOutputsTabTests() {
super(UITestPinHelper.EI1, UITestPinHelper.EI2, UITestPinHelper.EI3);
}

@Override
@BeforeEach
public void operationsInitialization() {
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 @@ -45,21 +48,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);
NatTableHelper.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
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Prashantkumar Khatri
* 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
Expand All @@ -9,14 +9,16 @@
*
* Contributors:
* Prashantkumar Khatri - initial API and implementation and/or initial documentation
* Andrea Zoitl - Creation of a fluid API design for UI SWTBot testing
*******************************************************************************/
package org.eclipse.fordiac.ide.test.ui.fbtype;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

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.swtbot.SWTBot4diacNatTable;
import org.eclipse.nebula.widgets.nattable.NatTable;
Expand All @@ -29,12 +31,13 @@

public class FunctionBlocksTabTests extends NatTableWithoutEditorBehaviorTests {

public FunctionBlocksTabTests() {
super(UITestNamesHelper.INTERNALFB1, UITestNamesHelper.INTERNALFB2, UITestNamesHelper.INTERNALFB3);
}

@Override
@BeforeEach
public void operationsInitialization() {
TESTVAR1 = UITestNamesHelper.INTERNALFB1;
TESTVAR2 = UITestNamesHelper.INTERNALFB2;
TESTVAR3 = UITestNamesHelper.INTERNALFB3;
final SWTBotFBType fbTypeBot = new SWTBotFBType(bot);
fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2,
UITestNamesHelper.TEMPLATEBASIC);
Expand All @@ -45,8 +48,8 @@ public void operationsInitialization() {
bot.editorByTitle(UITestNamesHelper.FBT_TEST_PROJECT2).show();
SWTBotPropertySheet.selectPropertyTabItem(UITestNamesHelper.FUNCTIONAL__BLOCKS, propertiesBot);
natTable = propertiesBot.widget(WidgetMatcherFactory.widgetOfType(NatTable.class), 0);
natTableBot = new SWTBot4diacNatTable(natTable);
NatTableHelper.createNewVariableInDataTypeEditor(natTableBot);
swt4diacNatTable = new SWTBot4diacNatTable(natTable);
new SWTBotNatTable(bot, swt4diacNatTable).createNewVariableInDataTypeEditor();
}

@Override
Expand All @@ -61,8 +64,8 @@ public void tryToSetInValidInitialValue() {

@Override
public void changeDataTypeOfVariable() {
NatTableHelper.changeDataType(natTableBot, 1, UITestNamesHelper.INT_SMALL);
natTableBot.doubleclick(1, 2);
new SWTBotNatTable(bot, swt4diacNatTable).changeDataType(1, UITestNamesHelper.INT_SMALL);
swt4diacNatTable.doubleclick(1, 2);

bot.button(UITestNamesHelper.DOT_BUTTON).click();

Expand All @@ -75,12 +78,12 @@ public void changeDataTypeOfVariable() {

bot.button(UITestNamesHelper.OK).click();

assertEquals(natTableBot.getCellDataValueByPosition(1, 2), UITestNamesHelper.BOOL2BOOL);
assertEquals(swt4diacNatTable.getCellDataValueByPosition(1, 2), UITestNamesHelper.BOOL2BOOL);
}

@Override
public void tryToSetInValidDataType() {
NatTableHelper.setInvalidDataType(natTableBot, 1, 2, UITestNamesHelper.TESTVAR);
new SWTBotNatTable(bot, swt4diacNatTable).setInvalidDataType(1, 2, UITestNamesHelper.TESTVAR);
}

}
Loading

0 comments on commit 42fed24

Please sign in to comment.