Skip to content

Commit e1171c6

Browse files
committed
Find Preferences menu under MacOS
1 parent f010f9b commit e1171c6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/PMDPreferencePage2Test.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.eclipse.core.runtime.ILogListener;
2323
import org.eclipse.core.runtime.IStatus;
2424
import org.eclipse.core.runtime.Platform;
25+
import org.eclipse.jface.preference.PreferenceDialog;
2526
import org.eclipse.swt.SWT;
2627
import org.eclipse.swt.widgets.Button;
2728
import org.eclipse.swtbot.swt.finder.waits.WaitForObjectCondition;
@@ -30,6 +31,7 @@
3031
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
3132
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
3233
import org.eclipse.ui.PlatformUI;
34+
import org.eclipse.ui.dialogs.PreferencesUtil;
3335
import org.hamcrest.Matcher;
3436
import org.junit.After;
3537
import org.junit.Before;
@@ -71,7 +73,7 @@ public void cleanup() {
7173
*/
7274
@Test
7375
public void openPMDRuleConfiguration() {
74-
bot.menu().menu("Window", "Preferences").click();
76+
openPreferences();
7577
SWTBotShell preferencesDialog = bot.shell("Preferences");
7678
SWTBotTreeItem pmdItem = preferencesDialog.bot().tree(0).getTreeItem("PMD");
7779
pmdItem.click();
@@ -101,4 +103,13 @@ public void openPMDRuleConfiguration() {
101103
+ errors.stream().map(IStatus::getMessage).collect(Collectors.joining("\n")));
102104
}
103105
}
106+
107+
private void openPreferences() {
108+
// due to macosx, where the Preferences is not part of the Window menu but the application
109+
// menu, we programmatically open the preferences dialog and not try to find it via the menu.
110+
bot.getDisplay().execute(() -> {
111+
PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(bot.shell().widget, null, null, errors);
112+
dialog.open();
113+
});
114+
}
104115
}

0 commit comments

Comments
 (0)