Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reddeer tests fixing #2223

Merged
merged 3 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.eclipse.reddeer.core.reference.ReferencedComposite;
import org.eclipse.reddeer.jface.preference.PreferencePage;
import org.eclipse.reddeer.swt.impl.button.CheckBox;
import org.eclipse.reddeer.swt.impl.combo.LabeledCombo;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;

Expand All @@ -34,6 +35,7 @@ public class MavenPreferencePage extends PreferencePage {
private static final String DOWNLOAD_REPO_INDEX_UPDATES_ON_STARTUP="Download repository index updates on startup";
private static final String UPDATE_MAVEN_PROJECTS_ON_STARTUP="Update Maven projects on startup";
private static final String HIDE_FOLDERS_OF_PHYSICALLY_NESTED_MODULES="Hide folders of physically nested modules (experimental)";
private static final String GLOBAL_UPDATE_POLICY="Global Update Policy:";

/**
* Constructs the preference page with "Maven".
Expand Down Expand Up @@ -67,7 +69,11 @@ public MavenPreferencePage setOffline(boolean check) {
* @return true, if is do not auto update deps checked
*/
public boolean isDoNotAutoUpdateDepsChecked() {
return new CheckBox(this, MavenPreferencePage.DO_NOT_AUTO_UPDATE_DEPS).isChecked();
try {
return new CheckBox(this, MavenPreferencePage.DO_NOT_AUTO_UPDATE_DEPS).isChecked();
} catch (org.eclipse.reddeer.core.exception.CoreLayerException e) { // there is no CheckBox "Do Not Auto update..." starting 2023-09-M3 Eclipse
return "Never".equals(getGlobalUpdatePolicy());
}
}

/**
Expand All @@ -76,7 +82,15 @@ public boolean isDoNotAutoUpdateDepsChecked() {
* @param check the new do not auto update deps
*/
public MavenPreferencePage setDoNotAutoUpdateDeps(boolean check) {
new CheckBox(this, MavenPreferencePage.DO_NOT_AUTO_UPDATE_DEPS).toggle(check);
try {
new CheckBox(this, MavenPreferencePage.DO_NOT_AUTO_UPDATE_DEPS).toggle(check);
} catch (org.eclipse.reddeer.core.exception.CoreLayerException e) { // there is no CheckBox "Do Not Auto update..." starting 2023-09-M3 Eclipse
if (check) {
setGlobalUpdatePolicy("Never");
} else {
setGlobalUpdatePolicy("Default");
}
}
return this;
}

Expand Down Expand Up @@ -212,4 +226,23 @@ public MavenPreferencePage setHideFoldersOfPhysicalyNestedModules(boolean check)
new CheckBox(this, MavenPreferencePage.HIDE_FOLDERS_OF_PHYSICALLY_NESTED_MODULES).toggle(check);
return this;
}

/**
* Returns String with selected Global Update Policy combo item .
*
* @return selected Global Update Policy combo item
*/
public String getGlobalUpdatePolicy() {
return new LabeledCombo(MavenPreferencePage.GLOBAL_UPDATE_POLICY).getSelection();
}

/**
* Sets Global Update Policy .
*
* @param updatePolicyType type of Global Update Policy to select
*/
public MavenPreferencePage setGlobalUpdatePolicy(String updatePolicyType) {
new LabeledCombo(MavenPreferencePage.GLOBAL_UPDATE_POLICY).setSelection(updatePolicyType);
return this;
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<properties>
<tycho-version>2.7.5</tycho-version>
<tychoExtrasVersion>${tycho-version}</tychoExtrasVersion>
<eclipse-target-site>https://download.eclipse.org/staging/2023-09/</eclipse-target-site>
<eclipse-target-site>https://download.eclipse.org/releases/2023-09/</eclipse-target-site>
<swtbot-update-site>https://download.eclipse.org/technology/swtbot/snapshots/</swtbot-update-site>
<!-- when making final release, switch from S to R latest update site - https://github.com/eclipse/reddeer/issues/2100 -->
<!--eclipse-orbit-update-site>https://download.eclipse.org/tools/orbit/downloads/latest-R/</eclipse-orbit-update-site-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,26 @@
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.NewEnumCreationWizard;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.NewEnumWizardPage;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageOne;
import org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer;
import org.eclipse.reddeer.junit.runner.RedDeerSuite;
import org.eclipse.reddeer.requirements.cleanworkspace.CleanWorkspaceRequirement.CleanWorkspace;
import org.eclipse.reddeer.workbench.impl.editor.TextEditor;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;

@CleanWorkspace
@RunWith(RedDeerSuite.class)
public class EnumWizardTest {

@After
public void cleanUp() {
ProjectExplorer explorer = new ProjectExplorer();
explorer.open();

explorer.deleteAllProjects(true);
}

@Test
public void createEnumClass(){
JavaProjectWizard jp = new JavaProjectWizard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,33 @@ public class MavenPreferencePageTest {
private WorkbenchPreferenceDialog preferencesDialog = new WorkbenchPreferenceDialog();

private MavenPreferencePage mavenPreferencePage = new MavenPreferencePage(preferencesDialog);

@Test
public void checkGlobalUpdatePolicy() {
preferencesDialog.open();
preferencesDialog.select(mavenPreferencePage);

mavenPreferencePage.setGlobalUpdatePolicy("Always");
assertTrue("Always".equals(mavenPreferencePage.getGlobalUpdatePolicy()));
mavenPreferencePage.setGlobalUpdatePolicy("Daily");
assertTrue("Daily".equals(mavenPreferencePage.getGlobalUpdatePolicy()));
mavenPreferencePage.setGlobalUpdatePolicy("Hourly");
assertTrue("Hourly".equals(mavenPreferencePage.getGlobalUpdatePolicy()));;
mavenPreferencePage.setGlobalUpdatePolicy("Default");
assertTrue("Default".equals(mavenPreferencePage.getGlobalUpdatePolicy()));
mavenPreferencePage.setGlobalUpdatePolicy("Never");
assertTrue("Never".equals(mavenPreferencePage.getGlobalUpdatePolicy()));

preferencesDialog.cancel();
}

@Test
public void checkAllPreferences() {
preferencesDialog.open();
preferencesDialog.select(mavenPreferencePage);

mavenPreferencePage.setDebugOutput(true);
// mavenPreferencePage.setDoNotAutoUpdateDeps(true); # is not a part of 2023-09 Eclipse
mavenPreferencePage.setDoNotAutoUpdateDeps(true);
mavenPreferencePage.setDownloadArtifactJavadoc(true);
mavenPreferencePage.setDownloadArtifactSources(true);
mavenPreferencePage.setDownloadRepoIndexOnStartup(true);
Expand All @@ -43,14 +62,14 @@ public void checkAllPreferences() {
mavenPreferencePage.setUpdateMavenProjectsOnStartup(true);

assertTrue(mavenPreferencePage.isDebugOutputChecked());
// assertTrue(mavenPreferencePage.isDoNotAutoUpdateDepsChecked()); # is not a part of 2023-09 Eclipse
assertTrue(mavenPreferencePage.isDoNotAutoUpdateDepsChecked());
assertTrue(mavenPreferencePage.isDownloadArtifactJavadocChecked());
assertTrue(mavenPreferencePage.isDownloadArtifactSourcesChecked());
assertTrue(mavenPreferencePage.isDownloadRepoIndexOnStartupChecked());
assertTrue(mavenPreferencePage.isHideFoldersOfPhysicalyNestedModulesChecked());
assertTrue(mavenPreferencePage.isOfflineChecked());
assertTrue(mavenPreferencePage.isUpdateMavenProjectsOnStartupChecked());

preferencesDialog.cancel();
}

Expand All @@ -60,7 +79,7 @@ public void uncheckAllPreferences() {
preferencesDialog.select(mavenPreferencePage);

mavenPreferencePage.setDebugOutput(false);
// mavenPreferencePage.setDoNotAutoUpdateDeps(false); # is not a part of 2023-09 Eclipse
mavenPreferencePage.setDoNotAutoUpdateDeps(false);
mavenPreferencePage.setDownloadArtifactJavadoc(false);
mavenPreferencePage.setDownloadArtifactSources(false);
mavenPreferencePage.setDownloadRepoIndexOnStartup(false);
Expand All @@ -69,7 +88,7 @@ public void uncheckAllPreferences() {
mavenPreferencePage.setUpdateMavenProjectsOnStartup(false);

assertFalse(mavenPreferencePage.isDebugOutputChecked());
// assertFalse(mavenPreferencePage.isDoNotAutoUpdateDepsChecked()); # is not a part of 2023-09 Eclipse
assertFalse(mavenPreferencePage.isDoNotAutoUpdateDepsChecked());
assertFalse(mavenPreferencePage.isDownloadArtifactJavadocChecked());
assertFalse(mavenPreferencePage.isDownloadArtifactSourcesChecked());
assertFalse(mavenPreferencePage.isDownloadRepoIndexOnStartupChecked());
Expand Down
Loading