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.
Add WebBrowserPreferencePage, fixes eclipse-archived#2152
Signed-off-by: Ondrej Dockal <odockal@redhat.com>
- Loading branch information
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
....reddeer.eclipse/src/org/eclipse/reddeer/eclipse/ui/browser/WebBrowserPreferencePage.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,44 @@ | ||
/******************************************************************************* | ||
* 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.eclipse.ui.browser; | ||
|
||
import org.eclipse.reddeer.core.matcher.WithTextMatcher; | ||
import org.eclipse.reddeer.core.reference.ReferencedComposite; | ||
import org.eclipse.reddeer.jface.preference.PreferencePage; | ||
import org.eclipse.reddeer.swt.impl.button.RadioButton; | ||
|
||
/** | ||
* Class represents General -> Web Browser Preferences page | ||
* | ||
* @author Ondrej Dockal | ||
* | ||
*/ | ||
public class WebBrowserPreferencePage extends PreferencePage { | ||
|
||
public WebBrowserPreferencePage(ReferencedComposite composite) { | ||
super(composite, new String[]{"General", "Web Browser"}); | ||
} | ||
|
||
public void toggleInternalBrowser() { | ||
getInternalBrowserCheckBox().toggle(true); | ||
} | ||
|
||
public void toggleExternalBrowser() { | ||
getExternalBrowserCheckBox().toggle(true); | ||
} | ||
|
||
public RadioButton getInternalBrowserCheckBox() { | ||
return new RadioButton(new WithTextMatcher("Use &internal web browser")); | ||
} | ||
|
||
public RadioButton getExternalBrowserCheckBox() { | ||
return new RadioButton(new WithTextMatcher("Use e&xternal web browser")); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...se.test/src/org/eclipse/reddeer/eclipse/test/ui/browser/WebBrowserPreferencePageTest.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,59 @@ | ||
/******************************************************************************* | ||
* 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.eclipse.test.ui.browser; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.eclipse.reddeer.direct.preferences.Preferences; | ||
import org.eclipse.reddeer.eclipse.ui.browser.WebBrowserPreferencePage; | ||
import org.eclipse.reddeer.workbench.ui.dialogs.WorkbenchPreferenceDialog; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
/** | ||
* | ||
* @author odockal | ||
* | ||
*/ | ||
public class WebBrowserPreferencePageTest { | ||
|
||
private static String BROWSER_PLUGIN = "org.eclipse.ui.browser"; | ||
private static String BROWSER_KEY = "browser-choice"; | ||
|
||
private WebBrowserPreferencePage page; | ||
private WorkbenchPreferenceDialog dialog; | ||
|
||
@Before | ||
public void setup() { | ||
dialog = new WorkbenchPreferenceDialog(); | ||
page = new WebBrowserPreferencePage(dialog); | ||
dialog.open(); | ||
|
||
dialog.select(page); | ||
} | ||
|
||
@Test | ||
public void testBrowserPreferencePage() { | ||
assertEquals("1", Preferences.get(BROWSER_PLUGIN, BROWSER_KEY)); | ||
page.toggleExternalBrowser(); | ||
page.apply(); | ||
assertEquals("1", Preferences.get(BROWSER_PLUGIN, BROWSER_KEY)); | ||
page.toggleInternalBrowser(); | ||
page.apply(); | ||
assertEquals("0", Preferences.get(BROWSER_PLUGIN, BROWSER_KEY)); | ||
} | ||
|
||
@After | ||
public void cleanup() { | ||
dialog.cancel(); | ||
} | ||
|
||
} |