1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

swtbot: Look for "Eclipse" in the shell title instead of "Eclipse SDK"

This allows running the tests with the Eclipse Platform product.

Change-Id: I0027654e5b2a885d656f9610459b4d4beaa875ce
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/36731
Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com>
Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
Marc-Andre Laperle 2014-11-19 22:49:57 -05:00
parent 39b1ed1b97
commit f7cf5a154f
2 changed files with 23 additions and 14 deletions

View file

@ -17,8 +17,8 @@ import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withRe
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withStyle;
import static org.eclipse.swtbot.swt.finder.waits.Conditions.waitForWidget;
import static org.eclipse.swtbot.swt.finder.waits.Conditions.widgetIsEnabled;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
@ -64,17 +64,8 @@ public abstract class AbstractTest {
SWTBotPreferences.PLAYBACK_DELAY = 10;
bot = new SWTWorkbenchBot();
bot.sleep(5000);
mainShell = null;
for (int i = 0, attempts = 100; i < attempts; i++) {
for (SWTBotShell shell : bot.shells()) {
if (shell.getText().contains("Eclipse Platform")) {
mainShell = shell;
shell.setFocus();
break;
}
}
}
assertNotNull(mainShell);
mainShell = getMainShell();
// Close the Welcome view if it exists
try {
bot.viewByTitle("Welcome").close();
@ -305,7 +296,7 @@ public abstract class AbstractTest {
.toolbarDropDownButton("Display Selected Console");
org.hamcrest.Matcher<MenuItem> withRegex = withRegex(".*" + consoleType
+ ".*");
bot.shell("C/C++ - Eclipse Platform").activate();
focusMainShell();
b.menuItem(withRegex).click();
try {
b.pressShortcut(KeyStroke.getInstance("ESC"));
@ -315,6 +306,24 @@ public abstract class AbstractTest {
return view;
}
/**
* Focus on the main window
*/
public static void focusMainShell() {
SWTBotShell shell = getMainShell();
shell.activate();
}
private static SWTBotShell getMainShell() {
for (SWTBotShell shellBot : bot.shells()) {
if (shellBot.getText().toLowerCase().contains("eclipse")) {
return shellBot;
}
}
fail("Could not find main shell");
return null;
}
@After
public void cleanUp() {
exitProjectFolder();

View file

@ -162,7 +162,7 @@ public class TestEnvironmentVars extends AbstractTest {
// the script
clickContextMenu(projectExplorer.bot().tree().select(projectName),
"Reconfigure Project");
bot.shell("C/C++ - Eclipse Platform").activate();
focusMainShell();
bot.sleep(3000);
SWTBotView consoleView = bot.viewByPartName("Console");
consoleView.setFocus();