|
1 | 1 | /*******************************************************************************
|
2 |
| - * Copyright (c) 2017, 2021 QNX Software Systems and others. |
| 2 | + * Copyright (c) 2017, 2024 Renesas Electronics Europe and others. |
3 | 3 | *
|
4 | 4 | * This program and the accompanying materials
|
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0
|
|
11 | 11 | package org.eclipse.launchbar.ui.tests.internal;
|
12 | 12 |
|
13 | 13 | import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withPartName;
|
| 14 | +import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType; |
14 | 15 | import static org.junit.jupiter.api.Assertions.fail;
|
15 | 16 |
|
16 | 17 | import java.util.concurrent.TimeUnit;
|
| 18 | +import java.util.concurrent.atomic.AtomicReference; |
17 | 19 |
|
18 | 20 | import org.eclipse.core.runtime.CoreException;
|
19 | 21 | import org.eclipse.debug.core.DebugPlugin;
|
|
24 | 26 | import org.eclipse.launchbar.ui.tests.SWTBotConfigSelector;
|
25 | 27 | import org.eclipse.launchbar.ui.tests.SWTBotConfigSelector.EditConfigDialog;
|
26 | 28 | import org.eclipse.launchbar.ui.tests.SWTBotConfigSelector.NewConfigDialog;
|
| 29 | +import org.eclipse.swt.widgets.Text; |
27 | 30 | import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
|
28 | 31 | import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
|
29 | 32 | import org.eclipse.swtbot.swt.finder.SWTBot;
|
@@ -139,4 +142,50 @@ public String getFailureMessage() {
|
139 | 142 | }
|
140 | 143 | });
|
141 | 144 | }
|
| 145 | + |
| 146 | + /** |
| 147 | + * Tests that the Launch Configuration, when opened via the Launch Bar, displays a warning |
| 148 | + * in the message area. |
| 149 | + * @see {@link WarningLaunchConfigTab} |
| 150 | + * @see {@code org.eclipse.launchbar.ui.tests/plugin.xml} |
| 151 | + */ |
| 152 | + @Test |
| 153 | + @Timeout(value = 2, unit = TimeUnit.MINUTES) |
| 154 | + public void createNewLaunchConfigWithWarning() throws Exception { |
| 155 | + // Test message. Needs to be effectively final. |
| 156 | + AtomicReference<String> errorMessage = new AtomicReference<>(); |
| 157 | + |
| 158 | + // Create config with launchbar |
| 159 | + bot.waitUntil(new ICondition() { |
| 160 | + @Override |
| 161 | + public void init(SWTBot bot) { |
| 162 | + /* |
| 163 | + * Use the Launch Bar new Launch Config and create an Eclipse Application Launch Config. |
| 164 | + * This will include a WarningLaunchConfigTab tab which has a warning set in it. |
| 165 | + */ |
| 166 | + NewConfigDialog dialog = new SWTBotConfigSelector(bot).newConfigDialog(); |
| 167 | + dialog.setMode("Debug").setType("Eclipse Application").next(); |
| 168 | + |
| 169 | + // Select the warning tab, which sets the Launch Config message area to contain a warning. |
| 170 | + dialog.bot().cTabItem(WarningLaunchConfigTab.TAB_NAME).activate(); |
| 171 | + |
| 172 | + // Get the Launch Config message area and stash the warning message for testing later |
| 173 | + int indexOfErrorLabel = dialog.bot().widgets(widgetOfType(Text.class)).size() - 1; |
| 174 | + errorMessage.set(dialog.bot().text(indexOfErrorLabel).getText()); |
| 175 | + |
| 176 | + dialog.finish(); |
| 177 | + } |
| 178 | + |
| 179 | + @Override |
| 180 | + public boolean test() throws Exception { |
| 181 | + return errorMessage.get() != null && errorMessage.get().equals(WarningLaunchConfigTab.WARNING_MESSAGE); |
| 182 | + } |
| 183 | + |
| 184 | + @Override |
| 185 | + public String getFailureMessage() { |
| 186 | + return String.format("Incorrect warning message; expected=%s, actual=%s", |
| 187 | + WarningLaunchConfigTab.WARNING_MESSAGE, errorMessage.get()); |
| 188 | + } |
| 189 | + }); |
| 190 | + } |
142 | 191 | }
|
0 commit comments