Skip to content

Commit

Permalink
added method for select one variable, renamed select mathods, renamed
Browse files Browse the repository at this point in the history
variables, added check for overwrite variable

Signed-off-by: Oleksii Korniienko <olkornii@redhat.com>
  • Loading branch information
olkornii authored and odockal committed May 25, 2021
1 parent 13dd7be commit 7d111a0
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@

import java.util.List;

import org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException;
import org.eclipse.reddeer.common.wait.TimePeriod;
import org.eclipse.reddeer.common.wait.WaitUntil;
import org.eclipse.reddeer.swt.api.TableItem;
import org.eclipse.reddeer.swt.condition.ShellIsAvailable;
import org.eclipse.reddeer.swt.impl.button.OkButton;
import org.eclipse.reddeer.swt.impl.button.PushButton;
import org.eclipse.reddeer.swt.impl.button.RadioButton;
import org.eclipse.reddeer.swt.impl.button.YesButton;
import org.eclipse.reddeer.swt.impl.table.DefaultTable;
import org.eclipse.reddeer.swt.impl.table.DefaultTableItem;
import org.eclipse.reddeer.swt.impl.text.LabeledText;
Expand All @@ -33,6 +36,7 @@ public class EnvironmentTab extends LaunchConfigurationTab {
private static final String ADD_SHELL_TITLE = "New Environment Variable";
private static final String SELECT_SHELL_TITLE = "Select Environment Variables";
private static final String EDIT_SHELL_TITLE = "Edit Environment Variable";
private static final String OVERWRITE_SHELL_TITLE = "Overwrite variable?";

public EnvironmentTab() {
super("Environment");
Expand All @@ -43,62 +47,94 @@ public EnvironmentTab() {
*
* @return list of items
*/
public List<TableItem> getVariables() {
public List<TableItem> getAllVariables() {
return new DefaultTable().getItems();
}

/**
* Return the environment variable by name
*
* @return Environment Tab item
*/
public TableItem getVariable(String variableName) {
return new DefaultTable().getItem(variableName);
}

/**
* Return the environment variable by id
*
* @return Environment Tab item
*/
public TableItem getVariable(int variableId) {
return new DefaultTable().getItem(variableId);
}

/**
* Add new environment variable
*
* @param Name variable name
* @param Value variable value
* @param name variable name
* @param value variable value
*/
public void add(String name, String nalue) {
new PushButton("Add...").click();
new WaitUntil(new ShellIsAvailable(ADD_SHELL_TITLE));
new LabeledText("Name:").setText(name);
new LabeledText("Value:").setText(nalue);
new OkButton().click();
try {
new WaitUntil(new ShellIsAvailable(OVERWRITE_SHELL_TITLE), TimePeriod.SHORT);
new YesButton().click();
} catch (WaitTimeoutExpiredException e) {
}
}

/**
* Select environment variable by name
*
* @param selectVariable variable name for select
* @param variableName variable name for select
*/
public void select(String selectVariable) {
public void selectEnvironmentVariable(String variableName) {
new PushButton("Select...").click();
new WaitUntil(new ShellIsAvailable(SELECT_SHELL_TITLE));
new DefaultTableItem(selectVariable).setChecked(true);
new OkButton().click();
new DefaultTableItem(variableName).setChecked(true);
OkButton oB = new OkButton();
if (oB.isEnabled()) {
oB.click();
}
}

/**
* Select environment variable by id
*
* @param id variable index
* @param variableId variable index for select
*/
public void select(int id) {
public void selectEnvironmentVariable(int variableId) {
new PushButton("Select...").click();
new WaitUntil(new ShellIsAvailable(SELECT_SHELL_TITLE));
new DefaultTable().getItem(id).setChecked(true);
new OkButton().click();
new DefaultTable().getItem(variableId).setChecked(true);
OkButton oB = new OkButton();
if (oB.isEnabled()) {
oB.click();
}
}

/**
* Select/deselect all environment variables in select button list
*
* @param selectAllBool true if need to select all variables, false for deselect
*/
public void select(boolean selectAllBool) {
public void selectEnvironmentVariable(boolean selectAllBool) {
new PushButton("Select...").click();
new WaitUntil(new ShellIsAvailable(SELECT_SHELL_TITLE));
if (selectAllBool) {
new PushButton("Select All").click();
} else {
new PushButton("Deselect All").click();
}
new OkButton().click();
OkButton oB = new OkButton();
if (oB.isEnabled()) {
oB.click();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@

@RunWith(RedDeerSuite.class)
@OpenPerspective(JavaPerspective.class)
public class EnvironmentLaunchConfigurationTabTest {
public class EnvironmentTabTest {

private static final String CONFIGURATION_NAME = EnvironmentLaunchConfigurationTabTest.class + "_test_config";
private static final String CONFIGURATION_NAME = EnvironmentTabTest.class + "_test_config";

protected LaunchConfigurationsDialog dialog;

Expand All @@ -61,38 +61,38 @@ public void testEnvironmentTab() {

EnvironmentTab envTab = new EnvironmentTab();
envTab.activate();
int should_be_var_count = envTab.getVariables().size();
int should_be_var_count = envTab.getAllVariables().size();

envTab.add("test_name", "test_value");
should_be_var_count++;
int add_env_count = envTab.getVariables().size();
int add_env_count = envTab.getAllVariables().size();
assertTrue(should_be_var_count == add_env_count);

envTab.select(0);
envTab.selectEnvironmentVariable(0);
should_be_var_count++;
int select_env_count = envTab.getVariables().size();
int select_env_count = envTab.getAllVariables().size();
assertTrue(should_be_var_count == select_env_count);

new DefaultTable().select(0);
envTab.getVariable(0).select();
envTab.remove();
should_be_var_count--;
int remove_env_count = envTab.getVariables().size();
int remove_env_count = envTab.getAllVariables().size();
assertTrue(should_be_var_count == remove_env_count);

new DefaultTable().select(0);
envTab.getVariable("test_name").select();
envTab.edit("test_new", "test_new");
String item_text = new DefaultTable().getItem(0).getText();
assertTrue(item_text.contains("test_new"));

new DefaultTable().select(0);
envTab.getVariable("test_new").select();
envTab.copy();
envTab.remove();
should_be_var_count--;
int copy_env_count = envTab.getVariables().size();
int copy_env_count = envTab.getAllVariables().size();
assertTrue(should_be_var_count == copy_env_count);
envTab.paste();
should_be_var_count++;
int paste_env_count = envTab.getVariables().size();
int paste_env_count = envTab.getAllVariables().size();
assertTrue(should_be_var_count == paste_env_count);

envTab.getReplaceRadioButton().click();
Expand Down

0 comments on commit 7d111a0

Please sign in to comment.