-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix eclipse.test tests, add DisableOomphRecorder Requirement
Signed-off-by: Ondrej Dockal <odockal@redhat.com>
- Loading branch information
Showing
6 changed files
with
174 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...quirements/src/org/eclipse/reddeer/requirements/preferences/OomphRecorderRequirement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 odockal@redhat.com | ||
* | ||
*/ | ||
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 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...t/src/org/eclipse/reddeer/requirements/test/preferences/OomphRecorderRequirementTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}; | ||
} | ||
|
||
|
||
} |