Skip to content

Commit

Permalink
NatWithoutEditorBehavoirTests test are running again eclipse-4diac#377
Browse files Browse the repository at this point in the history
The tests of class NatTableWithoutEditorBehaviorTests and tests of
derived classes are now adapted to the new test structure.

Addresses eclipse-4diac#377
  • Loading branch information
Andrearium committed Sep 16, 2024
1 parent bd72b8a commit 292af44
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 62 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,6 +9,7 @@
*
* 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;

Expand Down Expand Up @@ -50,8 +51,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);
SWTBotNatTable.createNewVariableInDataTypeEditor(natTableBot);
swt4diacNatTable = new SWTBot4diacNatTable(natTable);
new SWTBotNatTable(bot, swt4diacNatTable).createNewVariableInDataTypeEditor();
}

@Override
Expand All @@ -62,13 +63,13 @@ public void changeVariableNameWithButton() {
@Override
public void tryToSetInValidName() {
// Here Name column has same behavior as Data Type column or Invalid value
SWTBotNatTable.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
SWTBotNatTable.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,14 +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 @@ -42,7 +43,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);
SWTBotNatTable.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,6 +10,7 @@
* 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;

Expand Down Expand Up @@ -38,7 +39,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);
SWTBotNatTable.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,15 +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 Down Expand Up @@ -46,8 +47,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);
SWTBotNatTable.createNewVariableInDataTypeEditor(natTableBot);
swt4diacNatTable = new SWTBot4diacNatTable(natTable);
new SWTBotNatTable(bot, swt4diacNatTable).createNewVariableInDataTypeEditor();
}

@Override
Expand All @@ -62,8 +63,8 @@ public void tryToSetInValidInitialValue() {

@Override
public void changeDataTypeOfVariable() {
SWTBotNatTable.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 @@ -76,12 +77,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() {
SWTBotNatTable.setInvalidDataType(natTableBot, 1, 2, UITestNamesHelper.TESTVAR);
new SWTBotNatTable(bot, swt4diacNatTable).setInvalidDataType(1, 2, UITestNamesHelper.TESTVAR);
}

}
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,6 +9,7 @@
*
* 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;

Expand All @@ -25,12 +26,12 @@
import org.junit.jupiter.api.Test;

public class NatTableWithoutEditorBehaviorTests extends Abstract4diacUITests {
protected static SWTBot4diacNatTable natTableBot;
protected static NatTable natTable;
protected SWTBot4diacNatTable swt4diacNatTable;
protected NatTable natTable;

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$

/**
* Performs necessary tasks to make environment for testing the operations on
Expand All @@ -40,7 +41,6 @@ public class NatTableWithoutEditorBehaviorTests extends Abstract4diacUITests {
* and will confirm the visibility of the newly created type in system explorer
* and open the project in editor then will create a new variable in a Table.
*/
@SuppressWarnings("static-method")
@BeforeEach
public void operationsInitialization() {
final SWTBotFBType fbTypeBot = new SWTBotFBType(bot);
Expand All @@ -49,8 +49,8 @@ public void operationsInitialization() {
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);
SWTBotNatTable.createNewVariableInDataTypeEditor(natTableBot);
swt4diacNatTable = new SWTBot4diacNatTable(natTable);
new SWTBotNatTable(bot, swt4diacNatTable).createNewVariableInDataTypeEditor();
}

/**
Expand All @@ -61,11 +61,9 @@ public void operationsInitialization() {
* operation from another test method, basically this will prevent the
* redundancy.
*/
@SuppressWarnings("static-method")
@AfterEach
public void resetEnvironment() {
final SWTBotFBType fbTypeBot = new SWTBotFBType(bot);
fbTypeBot.deleteFBType(UITestNamesHelper.FBT_TEST_PROJECT2);
new SWTBotFBType(bot).deleteFBType(UITestNamesHelper.FBT_TEST_PROJECT2);
}

/**
Expand All @@ -75,10 +73,9 @@ public void resetEnvironment() {
* already exist in the Table. It then checks the new name is assigned properly
* or not.
*/
@SuppressWarnings("static-method")
@Test
public void renameVariable() {
SWTBotNatTable.changeCellValueInNatTbale(natTableBot, UITestNamesHelper.TESTVAR, 1, 1);
new SWTBotNatTable(bot, swt4diacNatTable).changeCellValueInNatTbale(UITestNamesHelper.TESTVAR, 1, 1);
}

/**
Expand All @@ -91,10 +88,9 @@ public void renameVariable() {
* whether OK button is enabled or not, it then click on OK button and assure
* the shell close. Then it checks for new name is assigned properly or not.
*/
@SuppressWarnings("static-method")
@Test
public void changeVariableNameWithButton() {
SWTBotNatTable.changeVariableNameWithButtonTool(natTableBot, 1, UITestNamesHelper.TESTVAR);
new SWTBotNatTable(bot, swt4diacNatTable).changeVariableNameWithButtonTool(1, UITestNamesHelper.TESTVAR);
}

/**
Expand All @@ -105,10 +101,9 @@ public void changeVariableNameWithButton() {
* 2nd variable to same name as 1st variable has. Then check if the name is
* successfully changed or not.
*/
@SuppressWarnings("static-method")
@Test
public void tryToChangeNameOfVariableWithExistingName() {
SWTBotNatTable.changeNameWithExistingName(natTableBot, 2, TESTVAR1, TESTVAR2);
new SWTBotNatTable(bot, swt4diacNatTable).changeNameWithExistingName(2, TESTVAR1, TESTVAR2);
}

/**
Expand All @@ -118,10 +113,9 @@ public void tryToChangeNameOfVariableWithExistingName() {
* will try to change the name of the variable with assigning invalid name. Then
* check if the name is successfully changed or not.
*/
@SuppressWarnings("static-method")
@Test
public void tryToSetInValidName() {
SWTBotNatTable.setInvalidName(natTableBot, 1, UITestNamesHelper.IF, TESTVAR1);
new SWTBotNatTable(bot, swt4diacNatTable).setInvalidName(1, UITestNamesHelper.IF, TESTVAR1);
}

/**
Expand All @@ -133,13 +127,13 @@ public void tryToSetInValidName() {
* variable by bringing it down. Then check if the order of variables is as
* expected or not.
*/
@SuppressWarnings("static-method")
@Test
public void reorderVariable() {
SWTBotNatTable.createNewVariableInDataTypeEditor(natTableBot);
SWTBotNatTable.createNewVariableInDataTypeEditor(natTableBot);
SWTBotNatTable.moveElementUp(natTableBot, 3);
SWTBotNatTable.moveElementDown(natTableBot, 1);
final SWTBotNatTable swtBotNatTable = new SWTBotNatTable(bot, swt4diacNatTable);
swtBotNatTable.createNewVariableInDataTypeEditor();
swtBotNatTable.createNewVariableInDataTypeEditor();
swtBotNatTable.moveElementUp(3);
swtBotNatTable.moveElementDown(1);
}

/**
Expand All @@ -149,10 +143,9 @@ public void reorderVariable() {
* not. It will first select the variable and then assigns data type to the
* selected variable. Then checks it's successfully changed or not.
*/
@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 @@ -163,10 +156,9 @@ public void changeDataTypeOfVariable() {
* to the selected variable. Then checks it's successfully changed or not or
* what changes is happened in the editor.
*/
@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 @@ -175,10 +167,9 @@ public void tryToSetInValidDataType() {
* The method will check if you can change the comment of the variable or not.
* It then checks the new comment is assigned properly or not.
*/
@SuppressWarnings("static-method")
@Test
public void changeCommentOfVariable() {
SWTBotNatTable.changeCellValueInNatTbale(natTableBot, UITestNamesHelper.TEST_COMMENT, 1, 3);
new SWTBotNatTable(bot, swt4diacNatTable).changeCellValueInNatTbale(UITestNamesHelper.TEST_COMMENT, 1, 3);
}

/**
Expand All @@ -187,11 +178,11 @@ public void changeCommentOfVariable() {
* The method will check if you can change the initial value of the variable or
* not. It then checks the new value is assigned properly or not.
*/
@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 @@ -202,9 +193,8 @@ public void changeInitialValueOfVariable() {
* initial value to the selected variable. Then checks it's successfully changed
* or not or what changes is happened in 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);
}
}
Loading

0 comments on commit 292af44

Please sign in to comment.