forked from eclipse-archived/reddeer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Internal Browser preferences requirement, fixes eclipse-arc…
…hived#2157 Signed-off-by: Ondrej Dockal <odockal@redhat.com>
- Loading branch information
Showing
5 changed files
with
98 additions
and
0 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
60 changes: 60 additions & 0 deletions
60
...requirements/src/org/eclipse/reddeer/requirements/browser/InternalBrowserRequirement.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,60 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Red Hat, Inc. | ||
* Distributed under license by Red Hat, Inc. All rights reserved. | ||
* This program is made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* Contributors: Red Hat, Inc. | ||
******************************************************************************/ | ||
|
||
package org.eclipse.reddeer.requirements.browser; | ||
|
||
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.junit.requirement.AbstractRequirement; | ||
import org.eclipse.reddeer.requirements.browser.InternalBrowserRequirement.UseInternalBrowser; | ||
|
||
/** | ||
* RedDeer Requirement that allows to setup an Internal Browser option as default | ||
* in Preferences: General -> Web Browser. | ||
* | ||
* @author Ondrej Dockal | ||
* | ||
*/ | ||
public class InternalBrowserRequirement extends AbstractRequirement<UseInternalBrowser>{ | ||
|
||
private static String BROWSER_PLUGIN = "org.eclipse.ui.browser"; | ||
private static String BROWSER_KEY = "browser-choice"; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
public @interface UseInternalBrowser { | ||
|
||
/** | ||
* String param dedicated to Internal Browser, change to "1" of necessary | ||
* @return 0 option to denote Internal browser, 1 for external | ||
*/ | ||
String browserChoice() default "0"; | ||
|
||
boolean cleanup() default false; | ||
} | ||
|
||
@Override | ||
public void fulfill() { | ||
Preferences.set(BROWSER_PLUGIN, BROWSER_KEY, annotation.browserChoice()); | ||
} | ||
|
||
@Override | ||
public void cleanUp() { | ||
if (annotation.cleanup()) { | ||
String choice = annotation.browserChoice().equals("0") ? "0" : "1"; | ||
Preferences.set(BROWSER_PLUGIN, BROWSER_KEY, choice); | ||
} | ||
} | ||
|
||
} |
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
27 changes: 27 additions & 0 deletions
27
...est/src/org/eclipse/reddeer/requirements/test/browser/InternalBrowserRequirementTest.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,27 @@ | ||
package org.eclipse.reddeer.requirements.test.browser; | ||
|
||
import org.eclipse.reddeer.junit.requirement.inject.InjectRequirement; | ||
import org.eclipse.reddeer.junit.runner.RedDeerSuite; | ||
import org.eclipse.reddeer.requirements.browser.InternalBrowserRequirement; | ||
import org.eclipse.reddeer.requirements.browser.InternalBrowserRequirement.UseInternalBrowser; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@UseInternalBrowser | ||
@RunWith(RedDeerSuite.class) | ||
public class InternalBrowserRequirementTest { | ||
|
||
@InjectRequirement | ||
InternalBrowserRequirement requirement; | ||
|
||
|
||
@Test | ||
public void testInternalBrowser() { | ||
|
||
} | ||
|
||
@Test | ||
public void testClenaupAction() { | ||
|
||
} | ||
} |