Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Fix eclipse.test tests, add DisableOomphRecorder Requirement #2176

Merged
merged 2 commits into from
Aug 24, 2022
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 @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.eclipse.reddeer.workbench.core.condition.JobIsRunning;

/**
* @deprecated
* Represents a TaskList on {@link TaskListView}.
*
* @author ldimaggi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@


/**
* @deprecated
* Represents the TaskRepositories view.
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.reddeer.workbench.core.condition.JobIsRunning;

/**
* @deprecated
* Represents a TaskRepository on {@link TaskRepositoriesView}.
*
* @author ldimaggi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.eclipse.reddeer.jface.wizard.WizardDialog;

/**
* @deprecated
* Represents new Mylyn Add Task Repository wizard
*
* @author ldimaggi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.reddeer.swt.impl.button.PushButton;

/**
* @deprecated
* Represents Mylyn Task Repository Properties dialog
*
* @author ldimaggi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions plugins/org.eclipse.reddeer.requirements/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<requirement class="org.eclipse.reddeer.requirements.db.DatabaseRequirement"/>
<requirement class="org.eclipse.reddeer.requirements.jre.JRERequirement"/>
<requirement class="org.eclipse.reddeer.requirements.openperspective.OpenPerspectiveRequirement"/>
<requirement class="org.eclipse.reddeer.requirements.preferences.OomphRecorderRequirement"/>
<requirement class="org.eclipse.reddeer.requirements.property.PropertyRequirement"/>
<requirement class="org.eclipse.reddeer.requirements.securestorage.SecureStorageRequirement"/>
<requirement class="org.eclipse.reddeer.requirements.server.apache.tomcat.ApacheTomcatServerRequirement"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 [email protected]
*
*/
public class OomphRecorderRequirement extends AbstractRequirement<DisableOomphRecorder> {

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
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -51,6 +52,7 @@
*/
@RunWith(RedDeerSuite.class)
@OpenPerspective(JavaPerspective.class)
@DisableOomphRecorder
public class BuildPathsPropertyPageTest {

private static final String TEST_PROJECT_NAME = "buildpathspropertypagetest";
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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<? extends Annotation> annotationType() {
return DisableOomphRecorder.class;
}

@Override
public boolean enabled() {
return enabled;
}
};
}


}