diff --git a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/jdt/ui/preferences/BuildPathsPropertyPage.java b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/jdt/ui/preferences/BuildPathsPropertyPage.java index c52f898711..5b609b618f 100644 --- a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/jdt/ui/preferences/BuildPathsPropertyPage.java +++ b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/jdt/ui/preferences/BuildPathsPropertyPage.java @@ -17,6 +17,7 @@ import org.eclipse.reddeer.common.logging.Logger; import org.eclipse.reddeer.common.wait.WaitWhile; import org.eclipse.reddeer.core.condition.WidgetIsFound; +import org.eclipse.reddeer.core.exception.CoreLayerException; import org.eclipse.reddeer.core.matcher.TreeItemTextMatcher; import org.eclipse.reddeer.core.matcher.WithMnemonicTextMatcher; import org.eclipse.reddeer.core.reference.ReferencedComposite; @@ -30,6 +31,7 @@ import org.eclipse.reddeer.swt.impl.button.OkButton; import org.eclipse.reddeer.swt.impl.button.PushButton; import org.eclipse.reddeer.swt.impl.button.YesButton; +import org.eclipse.reddeer.swt.impl.ctab.DefaultCTabItem; import org.eclipse.reddeer.swt.impl.shell.DefaultShell; import org.eclipse.reddeer.swt.impl.tab.DefaultTabItem; import org.eclipse.reddeer.swt.impl.table.DefaultTableItem; @@ -65,7 +67,13 @@ public BuildPathsPropertyPage(ReferencedComposite referencedComposite) { * Activates Source tab. */ public BuildPathsPropertyPage activateSourceTab() { - new DefaultTabItem(this, "Source").activate(); + try { + new DefaultCTabItem(this, "Source").activate(); + } + catch (CoreLayerException exc) { + // fallback for Eclipse older than 2022-09 where DefaultTabItem must be used + new DefaultTabItem(this, "Source").activate(); + } new WaitWhile(new JobIsRunning()); return this; } @@ -74,7 +82,13 @@ public BuildPathsPropertyPage activateSourceTab() { * Activates Projects tab. */ public BuildPathsPropertyPage activateProjectsTab() { - new DefaultTabItem(this, "Projects").activate(); + try { + new DefaultCTabItem(this, "Projects").activate(); + } + catch (CoreLayerException exc) { + // fallback for Eclipse older than 2022-09 where DefaultTabItem must be used + new DefaultTabItem(this, "Projects").activate(); + } new WaitWhile(new JobIsRunning()); return this; } @@ -83,7 +97,13 @@ public BuildPathsPropertyPage activateProjectsTab() { * Activates Libraries tab. */ public BuildPathsPropertyPage activateLibrariesTab() { - new DefaultTabItem(this, "Libraries").activate(); + try { + new DefaultCTabItem(this, "Libraries").activate(); + } + catch (CoreLayerException exc) { + // fallback for Eclipse older than 2022-09 where DefaultTabItem must be used + new DefaultTabItem(this, "Libraries").activate(); + } new WaitWhile(new JobIsRunning()); return this; } @@ -92,7 +112,13 @@ public BuildPathsPropertyPage activateLibrariesTab() { * Activates Order and Export tab. */ public BuildPathsPropertyPage activateOrderAndExportTab() { - new DefaultTabItem(this, "Order and Export").activate(); + try { + new DefaultCTabItem(this, "Order and Export").activate(); + } + catch (CoreLayerException exc) { + // fallback for Eclipse older than 2022-09 where DefaultTabItem must be used + new DefaultTabItem(this, "Order and Export").activate(); + } new WaitWhile(new JobIsRunning()); return this; } diff --git a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskList.java b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskList.java index 81b06b23c3..907abb0678 100644 --- a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskList.java +++ b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskList.java @@ -24,6 +24,7 @@ import org.eclipse.reddeer.workbench.core.condition.JobIsRunning; /** + * @deprecated * Represents a TaskList on {@link TaskListView}. * * @author ldimaggi diff --git a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskListView.java b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskListView.java index dc4b5c7e4f..8c8a7d073f 100644 --- a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskListView.java +++ b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskListView.java @@ -28,6 +28,7 @@ import org.eclipse.reddeer.workbench.impl.view.WorkbenchView; /** + * @deprecated * Represents the Task List view - to support Mylyn automated tests. * * @author ldimaggi diff --git a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskRepositoriesView.java b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskRepositoriesView.java index 3c993454b1..5735bd6fc7 100644 --- a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskRepositoriesView.java +++ b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskRepositoriesView.java @@ -34,6 +34,7 @@ /** + * @deprecated * Represents the TaskRepositories view. * */ diff --git a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskRepository.java b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskRepository.java index 1eb2662990..a108fdef48 100644 --- a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskRepository.java +++ b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/views/TaskRepository.java @@ -26,6 +26,7 @@ import org.eclipse.reddeer.workbench.core.condition.JobIsRunning; /** + * @deprecated * Represents a TaskRepository on {@link TaskRepositoriesView}. * * @author ldimaggi diff --git a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/wizards/NewRepositoryWizard.java b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/wizards/NewRepositoryWizard.java index a4158afe1b..c2a91ece69 100644 --- a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/wizards/NewRepositoryWizard.java +++ b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/wizards/NewRepositoryWizard.java @@ -14,6 +14,7 @@ import org.eclipse.reddeer.jface.wizard.WizardDialog; /** + * @deprecated * Represents new Mylyn Add Task Repository wizard * * @author ldimaggi diff --git a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/wizards/TaskRepositoryWizardDialog.java b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/wizards/TaskRepositoryWizardDialog.java index 8fd5657770..b8435a8671 100644 --- a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/wizards/TaskRepositoryWizardDialog.java +++ b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/mylyn/tasks/ui/wizards/TaskRepositoryWizardDialog.java @@ -17,6 +17,7 @@ import org.eclipse.reddeer.swt.impl.button.PushButton; /** + * @deprecated * Represents Mylyn Task Repository Properties dialog * * @author ldimaggi diff --git a/plugins/org.eclipse.reddeer.requirements/META-INF/MANIFEST.MF b/plugins/org.eclipse.reddeer.requirements/META-INF/MANIFEST.MF index c90503ea63..cf88d1c8a5 100644 --- a/plugins/org.eclipse.reddeer.requirements/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.reddeer.requirements/META-INF/MANIFEST.MF @@ -29,6 +29,7 @@ Export-Package: org.eclipse.reddeer.requirements.autobuilding, org.eclipse.reddeer.requirements.exception, org.eclipse.reddeer.requirements.jre, org.eclipse.reddeer.requirements.openperspective, + org.eclipse.reddeer.requirements.preferences, org.eclipse.reddeer.requirements.property, org.eclipse.reddeer.requirements.server, org.eclipse.reddeer.requirements.server.apache.tomcat, diff --git a/plugins/org.eclipse.reddeer.requirements/plugin.xml b/plugins/org.eclipse.reddeer.requirements/plugin.xml index 038f0c1ef9..df4bbb40f0 100644 --- a/plugins/org.eclipse.reddeer.requirements/plugin.xml +++ b/plugins/org.eclipse.reddeer.requirements/plugin.xml @@ -21,6 +21,7 @@ + diff --git a/plugins/org.eclipse.reddeer.requirements/src/org/eclipse/reddeer/requirements/preferences/OomphRecorderRequirement.java b/plugins/org.eclipse.reddeer.requirements/src/org/eclipse/reddeer/requirements/preferences/OomphRecorderRequirement.java new file mode 100644 index 0000000000..4c95668c3b --- /dev/null +++ b/plugins/org.eclipse.reddeer.requirements/src/org/eclipse/reddeer/requirements/preferences/OomphRecorderRequirement.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2022 Red Hat, Inc and others. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc - initial API and implementation + *******************************************************************************/ +package org.eclipse.reddeer.requirements.preferences; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.eclipse.reddeer.direct.preferences.Preferences; +import org.eclipse.reddeer.common.logging.Logger; +import org.eclipse.reddeer.junit.requirement.AbstractRequirement; +import org.eclipse.reddeer.requirements.preferences.OomphRecorderRequirement.DisableOomphRecorder; + +/** + * Disables oomph recorder using Direct API. + * + * @author odockal@redhat.com + * + */ +public class OomphRecorderRequirement extends AbstractRequirement { + + private static final Logger log = Logger.getLogger(OomphRecorderRequirement.class); + + private static final String OOMPH_PLUGIN_ID = "org.eclipse.oomph.setup.ui"; + + private static final String OOMPH_ENABLE_RECORDER_KEY = "enable.preference.recorder"; + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public @interface DisableOomphRecorder { + + /** + * Sets whether Oomph recorder is disabled or not. + * + * @return false if disabled + */ + boolean enabled() default false; + } + + @Override + public void fulfill() { + log.info(annotation.enabled() ? "Disabling" : "Enabling" + " Oomph preferences recorder"); + Preferences.set(OOMPH_PLUGIN_ID, OOMPH_ENABLE_RECORDER_KEY, Boolean.toString(annotation.enabled())); + } + + @Override + public void cleanUp() { + // nothing to do + } + +} diff --git a/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/jdt/ui/preferences/BuildPathsPropertyPageTest.java b/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/jdt/ui/preferences/BuildPathsPropertyPageTest.java index 636cf01fbd..305b87f6b3 100644 --- a/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/jdt/ui/preferences/BuildPathsPropertyPageTest.java +++ b/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/jdt/ui/preferences/BuildPathsPropertyPageTest.java @@ -36,6 +36,7 @@ import org.eclipse.reddeer.junit.execution.annotation.RunIf; import org.eclipse.reddeer.junit.runner.RedDeerSuite; import org.eclipse.reddeer.requirements.openperspective.OpenPerspectiveRequirement.OpenPerspective; +import org.eclipse.reddeer.requirements.preferences.OomphRecorderRequirement.DisableOomphRecorder; import org.eclipse.reddeer.workbench.core.condition.JobIsRunning; import org.junit.After; import org.junit.AfterClass; @@ -51,6 +52,7 @@ */ @RunWith(RedDeerSuite.class) @OpenPerspective(JavaPerspective.class) +@DisableOomphRecorder public class BuildPathsPropertyPageTest { private static final String TEST_PROJECT_NAME = "buildpathspropertypagetest"; diff --git a/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/mylyn/tasks/ui/view/TaskListViewTest.java b/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/mylyn/tasks/ui/view/TaskListViewTest.java deleted file mode 100644 index dfccac9d0e..0000000000 --- a/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/mylyn/tasks/ui/view/TaskListViewTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Red Hat, Inc and others. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc - initial API and implementation - *******************************************************************************/ -package org.eclipse.reddeer.eclipse.test.mylyn.tasks.ui.view; - -import static org.junit.Assert.assertTrue; - -import org.eclipse.reddeer.eclipse.mylyn.tasks.ui.views.TaskListView; -import org.eclipse.reddeer.junit.runner.RedDeerSuite; -import org.eclipse.reddeer.swt.api.TreeItem; -import org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * - * @author ldimaggi - * - */ -@RunWith(RedDeerSuite.class) -public class TaskListViewTest { - - @Test - public void getRepoTest() { - - TaskListView listView = new TaskListView(); - listView.open(); - listView.createLocalTaskTest(); - listView.open(); - - TreeItem retTask = (DefaultTreeItem)listView.getTask ("Uncategorized", "New Task"); - assertTrue ("task was found", (retTask.getText().equals("New Task"))); - } -} - - diff --git a/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/mylyn/tasks/ui/view/TaskRepositoriesViewTest.java b/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/mylyn/tasks/ui/view/TaskRepositoriesViewTest.java deleted file mode 100644 index 22b294f76e..0000000000 --- a/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/mylyn/tasks/ui/view/TaskRepositoriesViewTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Red Hat, Inc and others. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc - initial API and implementation - *******************************************************************************/ -package org.eclipse.reddeer.eclipse.test.mylyn.tasks.ui.view; - -import static org.junit.Assert.assertFalse; - -import java.util.List; - -import org.eclipse.reddeer.eclipse.mylyn.tasks.ui.views.TaskRepositoriesView; -import org.eclipse.reddeer.eclipse.mylyn.tasks.ui.views.TaskRepository; -import org.eclipse.reddeer.junit.runner.RedDeerSuite; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * - * @author ldimaggi - * - */ -@RunWith(RedDeerSuite.class) -public class TaskRepositoriesViewTest { - - @Test - public void getRepoTest() { - - TaskRepositoriesView view = new TaskRepositoriesView(); - view.open(); - - List repositories = view.getTaskRepositories(); - assertFalse ("repos are found", repositories.isEmpty()); - } -} diff --git a/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/ui/dialogs/ExplorerItemPropertyDialogTest.java b/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/ui/dialogs/ExplorerItemPropertyDialogTest.java index 3737ffe456..c59484e87f 100644 --- a/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/ui/dialogs/ExplorerItemPropertyDialogTest.java +++ b/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/ui/dialogs/ExplorerItemPropertyDialogTest.java @@ -36,7 +36,7 @@ @RunWith(RedDeerSuite.class) public class ExplorerItemPropertyDialogTest { - private static final String PROJECT_NAME = "Property test project"; + private static final String PROJECT_NAME = "PropertyTestProject"; private static DefaultProject project; diff --git a/tests/org.eclipse.reddeer.requirements.test/src/org/eclipse/reddeer/requirements/test/preferences/OomphRecorderRequirementTest.java b/tests/org.eclipse.reddeer.requirements.test/src/org/eclipse/reddeer/requirements/test/preferences/OomphRecorderRequirementTest.java new file mode 100644 index 0000000000..dfde750109 --- /dev/null +++ b/tests/org.eclipse.reddeer.requirements.test/src/org/eclipse/reddeer/requirements/test/preferences/OomphRecorderRequirementTest.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2022 Red Hat, Inc and others. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc - initial API and implementation + *******************************************************************************/ +package org.eclipse.reddeer.requirements.test.preferences; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.lang.annotation.Annotation; + +import org.eclipse.reddeer.direct.preferences.Preferences; +import org.eclipse.reddeer.junit.runner.RedDeerSuite; +import org.eclipse.reddeer.requirements.preferences.OomphRecorderRequirement; +import org.eclipse.reddeer.requirements.preferences.OomphRecorderRequirement.DisableOomphRecorder; +import org.eclipse.reddeer.swt.impl.toolbar.DefaultToolBar; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(RedDeerSuite.class) +public class OomphRecorderRequirementTest { + + private static final String OOMPH_PLUGIN_ID = "org.eclipse.oomph.setup.ui"; + private static final String OOMPH_ENABLE_RECORDER_KEY = "enable.preference.recorder"; + + private OomphRecorderRequirement requirementEnabled; + private OomphRecorderRequirement requirementDisabled; + + @Before + public void setupRequirement() { + requirementEnabled = new OomphRecorderRequirement(); + requirementEnabled.setDeclaration(createDisableOomphRecorderInstance(true)); + requirementDisabled = new OomphRecorderRequirement(); + requirementDisabled.setDeclaration(createDisableOomphRecorderInstance(false)); + } + + public DefaultToolBar getPreferencesToolBar() { + return new DefaultToolBar(); + } + + @Test + public void testEnableOomphRecorder() { + requirementEnabled.fulfill(); + String actualValue = Preferences.get(OOMPH_PLUGIN_ID, OOMPH_ENABLE_RECORDER_KEY); + assertTrue(Boolean.valueOf(actualValue)); + } + + @Test + public void testDisableOomphRecorder() { + requirementDisabled.fulfill(); + String actualValue = Preferences.get(OOMPH_PLUGIN_ID, OOMPH_ENABLE_RECORDER_KEY); + assertFalse(Boolean.valueOf(actualValue)); + } + + private DisableOomphRecorder createDisableOomphRecorderInstance(boolean enabled) { + return new DisableOomphRecorder() { + + @Override + public Class annotationType() { + return DisableOomphRecorder.class; + } + + @Override + public boolean enabled() { + return enabled; + } + }; + } + + +}