diff --git a/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/PMDPreferencePage2Test.java b/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/PMDPreferencePage2Test.java new file mode 100644 index 00000000..0a8f82bb --- /dev/null +++ b/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/PMDPreferencePage2Test.java @@ -0,0 +1,104 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + + +package net.sourceforge.pmd.eclipse.ui.preferences.br; + +import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf; +import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType; +import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic; +import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withStyle; +import static org.eclipse.swtbot.swt.finder.waits.Conditions.waitForWidget; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import org.eclipse.core.runtime.ILogListener; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swtbot.swt.finder.waits.WaitForObjectCondition; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.eclipse.ui.PlatformUI; +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import net.sourceforge.pmd.eclipse.AbstractSWTBotTest; + +public class PMDPreferencePage2Test extends AbstractSWTBotTest { + private List errors; + private ILogListener logListener; + + @Before + public void setup() { + errors = new ArrayList<>(); + logListener = new ILogListener() { + @Override + public void logging(IStatus status, String plugin) { + if (status.getSeverity() != IStatus.ERROR) { + return; + } + + String statusText = status.toString().toLowerCase(Locale.ROOT); + if (statusText.contains("pmd") || statusText.contains("unhandled event loop exception")) { + errors.add(status); + } + } + }; + Platform.getLog(PlatformUI.class).addLogListener(logListener); + } + + @After + public void cleanup() { + Platform.getLog(PlatformUI.class).removeLogListener(logListener); + } + + /** + * Simple smoke test to open the rule configuration preference pages. + * @see PMDPreferencePage2 + */ + @Test + public void openPMDRuleConfiguration() { + bot.menu().menu("Window", "Preferences").click(); + SWTBotShell preferencesDialog = bot.shell("Preferences"); + SWTBotTreeItem pmdItem = preferencesDialog.bot().tree(0).getTreeItem("PMD"); + pmdItem.click(); + pmdItem.expand(); + pmdItem.getNode("Rule Configuration").click(); + + + Matcher