Skip to content

Commit

Permalink
Add WebBrowserPreferencePage, fixes eclipse-archived#2152
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Dockal <odockal@redhat.com>
  • Loading branch information
odockal committed Jan 26, 2022
1 parent 4fc24cc commit 12fabc4
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
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"));
}
}
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();
}

}

0 comments on commit 12fabc4

Please sign in to comment.