|
22 | 22 | import org.eclipse.core.runtime.ILogListener; |
23 | 23 | import org.eclipse.core.runtime.IStatus; |
24 | 24 | import org.eclipse.core.runtime.Platform; |
| 25 | +import org.eclipse.jface.preference.PreferenceDialog; |
25 | 26 | import org.eclipse.swt.SWT; |
26 | 27 | import org.eclipse.swt.widgets.Button; |
27 | 28 | import org.eclipse.swtbot.swt.finder.waits.WaitForObjectCondition; |
|
30 | 31 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; |
31 | 32 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; |
32 | 33 | import org.eclipse.ui.PlatformUI; |
| 34 | +import org.eclipse.ui.dialogs.PreferencesUtil; |
33 | 35 | import org.hamcrest.Matcher; |
34 | 36 | import org.junit.After; |
35 | 37 | import org.junit.Before; |
@@ -71,7 +73,7 @@ public void cleanup() { |
71 | 73 | */ |
72 | 74 | @Test |
73 | 75 | public void openPMDRuleConfiguration() { |
74 | | - bot.menu().menu("Window", "Preferences").click(); |
| 76 | + openPreferences(); |
75 | 77 | SWTBotShell preferencesDialog = bot.shell("Preferences"); |
76 | 78 | SWTBotTreeItem pmdItem = preferencesDialog.bot().tree(0).getTreeItem("PMD"); |
77 | 79 | pmdItem.click(); |
@@ -101,4 +103,13 @@ public void openPMDRuleConfiguration() { |
101 | 103 | + errors.stream().map(IStatus::getMessage).collect(Collectors.joining("\n"))); |
102 | 104 | } |
103 | 105 | } |
| 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 | + } |
104 | 115 | } |
0 commit comments