Skip to content

Commit

Permalink
Fix another batch of tests and patches for 2022-09 eclipse. fixes #2156
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Dockal <odockal@redhat.com>
  • Loading branch information
odockal committed Sep 7, 2022
1 parent 6f4f3ce commit 6947534
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import org.eclipse.reddeer.core.reference.ReferencedComposite;
import org.eclipse.reddeer.swt.impl.button.CheckBox;
import org.eclipse.reddeer.swt.impl.button.LabeledCheckBox;
import org.eclipse.reddeer.swt.impl.button.RadioButton;
import org.eclipse.reddeer.swt.impl.text.LabeledText;

/**
Expand Down Expand Up @@ -53,7 +53,7 @@ public boolean getStaticMainMethodCheckboxState() {
* @return boolean state of the abstract checkbox
*/
public boolean getAbstractModifierCheckboxState() {
return new CheckBox(this, "abstract").isChecked();
return getAbstactModifierCheckBox().isChecked();
}

/**
Expand All @@ -62,7 +62,7 @@ public boolean getAbstractModifierCheckboxState() {
* @param toggle abstract modifier checkbox
*/
public NewClassWizardPage toggleAbstractModifierCheckbox(boolean toggle) {
new CheckBox(this, "abstract").toggle(toggle);
getAbstactModifierCheckBox().toggle(toggle);
return this;
}

Expand All @@ -72,7 +72,7 @@ public NewClassWizardPage toggleAbstractModifierCheckbox(boolean toggle) {
* @return boolean state of the final checkbox
*/
public boolean getFinalModifierCheckboxState() {
return new CheckBox(this, "final").isChecked();
return getFinalModifierCheckBox().isChecked();
}

/**
Expand All @@ -81,7 +81,7 @@ public boolean getFinalModifierCheckboxState() {
* @param toggle final modifier checkbox
*/
public NewClassWizardPage toggleFinalModifierCheckbox(boolean toggle) {
new CheckBox(this, "final").toggle(toggle);
getFinalModifierCheckBox().toggle(toggle);
return this;
}

Expand All @@ -103,4 +103,52 @@ public NewClassWizardPage setSuperclassName(String superclassName) {
public String getSuperclassName() {
return new LabeledText(this, "Superclass:").getText();
}

/**
* Return "abstract" check box object
* @return CheckBox for abstract modifier
*/
public CheckBox getAbstactModifierCheckBox() {
return new CheckBox(this, "abstract");
}

/**
* Return "final" check box object
* @return CheckBox for final modifier
*/
public CheckBox getFinalModifierCheckBox() {
return new CheckBox(this, "final");
}

/**
* Return "final" radio button object
* @return RadioButton for final modifier
*/
public RadioButton getFinalModifierRadioButton() {
return new RadioButton(this, "final");
}

/**
* Return "none" radio button object
* @return RadioButton for none modifier
*/
public RadioButton getNoneModifierRadioButton() {
return new RadioButton(this, "none");
}

/**
* Return "sealed" radio button object
* @return RadioButton for sealed modifier
*/
public RadioButton getSealedModifierRadioButton() {
return new RadioButton(this, "sealed");
}

/**
* Return "non-sealed" radio button object
* @return RadioButton for non-sealed modifier
*/
public RadioButton getNonSealedModifierRadioButton() {
return new RadioButton(this, "non-sealed");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

package org.eclipse.reddeer.eclipse.test.jdt.ui.wizards;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand Down Expand Up @@ -173,10 +175,20 @@ public void testSettingAndGettingInputAndCheckboxValues() {
classPage.toggleAbstractModifierCheckbox(true).getAbstractModifierCheckboxState());
assertTrue("State of abstract modifier should be 'false', but is not.",
!classPage.toggleAbstractModifierCheckbox(false).getAbstractModifierCheckboxState());
assertTrue("State of final modifier should be 'true', but is not.",
classPage.toggleFinalModifierCheckbox(true).getFinalModifierCheckboxState());
assertTrue("State of final modifier should be 'false', but is not.",
!classPage.toggleFinalModifierCheckbox(false).getFinalModifierCheckboxState());

classPage.getFinalModifierRadioButton().click();
assertTrue("State of final modifier should be 'true', but is not.",
classPage.getFinalModifierRadioButton().isSelected());
classPage.getNoneModifierRadioButton().click();
assertTrue("State of none modifier should be 'true', but is not.",
classPage.getNoneModifierRadioButton().isSelected());
assertFalse("State of final modifier should be 'false', but is not.",
classPage.getFinalModifierRadioButton().isSelected());

// check some modifier objects creation
assertNotNull(classPage.getAbstactModifierCheckBox());
assertNotNull(classPage.getNonSealedModifierRadioButton());
assertNotNull(classPage.getFinalModifierCheckBox());

// test toggling the checkbox for creating main method in newly created class
assertTrue("State of checkbox for creating main method should be 'disabled', but is not.",
Expand Down Expand Up @@ -247,14 +259,6 @@ public void testAddingAndRemovingNonexistingAndNotFullySpecifiedInterfaces() {
new PushButton("Cancel").click();
}

// try to add an extended interface, that is not fully specified by its name
try {
classPage.addExtendedInterface("Acl");
fail("RedDeer exception was not thrown when trying to add an extended interface, that is not fully specified by its name.");
} catch (RedDeerException e) {
new PushButton("Cancel").click();
}

// try to remove an extended interface, that is not on the list
try {
classPage.removeExtendedInterface("javax.accessibility.AccessibleAction");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
import java.util.List;

import org.eclipse.reddeer.common.exception.RedDeerException;
import org.eclipse.reddeer.common.matcher.RegexMatcher;
import org.eclipse.reddeer.common.wait.TimePeriod;
import org.eclipse.reddeer.common.wait.WaitUntil;
import org.eclipse.reddeer.common.wait.WaitWhile;
import org.eclipse.reddeer.core.matcher.WithTextMatcher;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.JavaProjectWizard;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.NewInterfaceCreationWizardPage;
Expand All @@ -29,6 +32,7 @@
import org.eclipse.reddeer.eclipse.ui.perspectives.JavaPerspective;
import org.eclipse.reddeer.junit.runner.RedDeerSuite;
import org.eclipse.reddeer.requirements.openperspective.OpenPerspectiveRequirement.OpenPerspective;
import org.eclipse.reddeer.swt.condition.ShellIsAvailable;
import org.eclipse.reddeer.swt.impl.button.PushButton;
import org.eclipse.reddeer.workbench.condition.EditorWithTitleIsActive;
import org.eclipse.reddeer.workbench.handler.EditorHandler;
Expand Down Expand Up @@ -62,6 +66,11 @@ public static void setup() {

@After
public void closeAllEditors() {
ShellIsAvailable shell = new ShellIsAvailable(new WithTextMatcher(new RegexMatcher("[Extended|Implemented].*Interfaces Selection")));
new WaitWhile(shell, TimePeriod.SHORT, false);
if (shell.getResult() != null) {
shell.getResult().close();
}
EditorHandler.getInstance().closeAll(true);
}

Expand Down Expand Up @@ -226,14 +235,6 @@ public void testAddingAndRemovingNonexistingAndNotFullySpecifiedInterfaces() {
new PushButton("Cancel").click();
}

// try to add an extended interface, that is not fully specified by its name
try {
interfacePage.addExtendedInterface("Acl");
fail("RedDeer exception was not thrown when trying to add an extended interface, that is not fully specified by its name.");
} catch (RedDeerException e) {
new PushButton("Cancel").click();
}

// try to remove an extended interface, that is not on the list
try {
interfacePage.removeExtendedInterface("javax.accessibility.AccessibleAction");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public void setup() {

@Test
public void testBrowserPreferencePage() {
assertEquals("1", Preferences.get(BROWSER_PLUGIN, BROWSER_KEY));
page.toggleExternalBrowser();
page.apply();
assertEquals("1", Preferences.get(BROWSER_PLUGIN, BROWSER_KEY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;

import java.util.Arrays;
import java.util.List;

import org.eclipse.reddeer.eclipse.core.resources.DefaultProject;
Expand Down Expand Up @@ -71,12 +73,14 @@ public void addAll_removeTwo(){
ModifyModulesPage page = new ModifyModulesPage(dialog);
page.addAll();
dialog.finish();
List<String> expectedBefore = Arrays.asList(PROJECT_1, PROJECT_2, PROJECT_3);

List<ServerModule> modules = server.getModules();
assertThat(modules.size(), is(3));
assertThat(modules.get(0).getLabel().getName(), is(PROJECT_1));
assertThat(modules.get(1).getLabel().getName(), is(PROJECT_2));
assertThat(modules.get(2).getLabel().getName(), is(PROJECT_3));

modules.stream().forEach(mod -> {
assertTrue(expectedBefore.contains(mod.getLabel().getName()));
});

dialog = server.addAndRemoveModules();
page = new ModifyModulesPage(dialog);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.util.Arrays;
import java.util.List;

import org.eclipse.reddeer.eclipse.wst.server.ui.cnf.Server;
Expand Down Expand Up @@ -76,19 +78,24 @@ public void removeServerModule() {
ModifyModulesPage page = new ModifyModulesPage(dialog);
page.addAll();
dialog.finish();
List<String> expectedBefore = Arrays.asList(PROJECT_1, PROJECT_2, PROJECT_3);
List<String> expectedAfter = Arrays.asList(PROJECT_1, PROJECT_3);

List<ServerModule> modules = server.getModules();
assertThat(modules.size(), is(3));
assertThat(modules.get(0).getLabel().getName(), is(PROJECT_1));
assertThat(modules.get(1).getLabel().getName(), is(PROJECT_2));
assertThat(modules.get(2).getLabel().getName(), is(PROJECT_3));
modules.stream().forEach(mod -> {
assertTrue(expectedBefore.contains(mod.getLabel().getName()));
});

modules.get(0).remove();
ServerModule module = modules.stream().filter(item -> item.getLabel().getName().equals(PROJECT_2)).findFirst().orElse(null);
assertNotNull(module);
module.remove();

modules = server.getModules();
assertThat(modules.size(), is(2));
assertThat(modules.get(0).getLabel().getName(), is(PROJECT_2));
assertThat(modules.get(1).getLabel().getName(), is(PROJECT_3));
modules.stream().forEach(mod -> {
assertTrue(expectedAfter.contains(mod.getLabel().getName()));
});
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected static void createServer(String name) {

NewServerWizardPage newServerPage = new NewServerWizardPage(wizardDialog);
newServerPage.selectType("Basic", TestServer.NAME);
newServerPage.setName(name);
newServerPage.setName(name);

wizardDialog.finish();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,4 @@ public void stopModule(IModule[] module, IProgressMonitor monitor) throws CoreEx
AbstractWait.sleep(TimePeriod.SHORT);
setModuleState(module, IServer.STATE_STOPPED);
}


}

0 comments on commit 6947534

Please sign in to comment.