Skip to content

Commit

Permalink
fixed code smells
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksii Korniienko <olkornii@redhat.com>
  • Loading branch information
olkornii authored and odockal committed May 25, 2021
1 parent 20be714 commit 13dd7be
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

import java.util.List;

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;
Expand All @@ -26,9 +28,13 @@
* @author Oleksii Korniienko olkornii@redhat.com
*
*/
public class EnvironmentLaunchConfigurationTab extends LaunchConfigurationTab {
public class EnvironmentTab extends LaunchConfigurationTab {

public EnvironmentLaunchConfigurationTab() {
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";

public EnvironmentTab() {
super("Environment");
}

Expand All @@ -37,7 +43,7 @@ public EnvironmentLaunchConfigurationTab() {
*
* @return list of items
*/
public List<TableItem> get_variables() {
public List<TableItem> getVariables() {
return new DefaultTable().getItems();
}

Expand All @@ -47,21 +53,23 @@ public List<TableItem> get_variables() {
* @param Name variable name
* @param Value variable value
*/
public void add(String Name, String Value) {
public void add(String name, String nalue) {
new PushButton("Add...").click();
new LabeledText("Name:").setText(Name);
new LabeledText("Value:").setText(Value);
new WaitUntil(new ShellIsAvailable(ADD_SHELL_TITLE));
new LabeledText("Name:").setText(name);
new LabeledText("Value:").setText(nalue);
new OkButton().click();
}

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

Expand All @@ -72,17 +80,19 @@ public void select(String Name) {
*/
public void select(int id) {
new PushButton("Select...").click();
new WaitUntil(new ShellIsAvailable(SELECT_SHELL_TITLE));
new DefaultTable().getItem(id).setChecked(true);
new OkButton().click();
}

/**
* Select/deselect all environment variables in select button list
*
* @param id variable index
* @param selectAllBool true if need to select all variables, false for deselect
*/
public void select(boolean selectAllBool) {
new PushButton("Select...").click();
new WaitUntil(new ShellIsAvailable(SELECT_SHELL_TITLE));
if (selectAllBool) {
new PushButton("Select All").click();
} else {
Expand All @@ -94,13 +104,14 @@ public void select(boolean selectAllBool) {
/**
* edit environment variable
*
* @param Name new variable name
* @param Value new variable value
* @param name new variable name
* @param value new variable value
*/
public void edit(String Name, String Value) {
public void edit(String name, String value) {
new PushButton("Edit...").click();
new LabeledText("Name:").setText(Name);
new LabeledText("Value:").setText(Value);
new WaitUntil(new ShellIsAvailable(EDIT_SHELL_TITLE));
new LabeledText("Name:").setText(name);
new LabeledText("Value:").setText(value);
new OkButton().click();
}

Expand All @@ -127,15 +138,19 @@ public void paste() {

/**
* Append environment to native environment
*
* @return append radio button
*/
public void append() {
new RadioButton("Append environment to native environment").click();
public RadioButton getAppendRadioButton() {
return new RadioButton("Append environment to native environment");
}

/**
* Replace native environment with specified environment
*
* @return replace radio button
*/
public void replace() {
new RadioButton("Replace native environment with specified environment").click();
public RadioButton getReplaceRadioButton() {
return new RadioButton("Replace native environment with specified environment");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.eclipse.reddeer.common.exception.RedDeerException;
import org.eclipse.reddeer.common.wait.TimePeriod;
import org.eclipse.reddeer.common.wait.WaitUntil;
import org.eclipse.reddeer.eclipse.debug.ui.launchConfigurations.EnvironmentLaunchConfigurationTab;
import org.eclipse.reddeer.eclipse.debug.ui.launchConfigurations.EnvironmentTab;
import org.eclipse.reddeer.eclipse.debug.ui.launchConfigurations.JUnitLaunchConfiguration;
import org.eclipse.reddeer.eclipse.debug.ui.launchConfigurations.LaunchConfigurationsDialog;
import org.eclipse.reddeer.eclipse.debug.ui.launchConfigurations.RunConfigurationsDialog;
Expand Down Expand Up @@ -59,24 +59,24 @@ public void closeDialog() {
public void testEnvironmentTab() {
dialog.create(new JUnitLaunchConfiguration(), CONFIGURATION_NAME);

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

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

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

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

new DefaultTable().select(0);
Expand All @@ -88,16 +88,16 @@ public void testEnvironmentTab() {
envTab.copy();
envTab.remove();
should_be_var_count--;
int copy_env_count = envTab.get_variables().size();
int copy_env_count = envTab.getVariables().size();
assertTrue(should_be_var_count == copy_env_count);
envTab.paste();
should_be_var_count++;
int paste_env_count = envTab.get_variables().size();
int paste_env_count = envTab.getVariables().size();
assertTrue(should_be_var_count == paste_env_count);

envTab.replace();
envTab.getReplaceRadioButton().click();
assertTrue(new RadioButton("Replace native environment with specified environment").isSelected());
envTab.append();
envTab.getAppendRadioButton().click();
assertTrue(new RadioButton("Append environment to native environment").isSelected());
}
}

0 comments on commit 13dd7be

Please sign in to comment.