mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 18:05:33 +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:
parent
39b1ed1b97
commit
f7cf5a154f
2 changed files with 23 additions and 14 deletions
|
@ -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.matchers.WidgetMatcherFactory.withStyle;
|
||||||
import static org.eclipse.swtbot.swt.finder.waits.Conditions.waitForWidget;
|
import static org.eclipse.swtbot.swt.finder.waits.Conditions.waitForWidget;
|
||||||
import static org.eclipse.swtbot.swt.finder.waits.Conditions.widgetIsEnabled;
|
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.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IProjectNature;
|
import org.eclipse.core.resources.IProjectNature;
|
||||||
|
@ -64,17 +64,8 @@ public abstract class AbstractTest {
|
||||||
SWTBotPreferences.PLAYBACK_DELAY = 10;
|
SWTBotPreferences.PLAYBACK_DELAY = 10;
|
||||||
bot = new SWTWorkbenchBot();
|
bot = new SWTWorkbenchBot();
|
||||||
bot.sleep(5000);
|
bot.sleep(5000);
|
||||||
mainShell = null;
|
mainShell = getMainShell();
|
||||||
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);
|
|
||||||
// Close the Welcome view if it exists
|
// Close the Welcome view if it exists
|
||||||
try {
|
try {
|
||||||
bot.viewByTitle("Welcome").close();
|
bot.viewByTitle("Welcome").close();
|
||||||
|
@ -305,7 +296,7 @@ public abstract class AbstractTest {
|
||||||
.toolbarDropDownButton("Display Selected Console");
|
.toolbarDropDownButton("Display Selected Console");
|
||||||
org.hamcrest.Matcher<MenuItem> withRegex = withRegex(".*" + consoleType
|
org.hamcrest.Matcher<MenuItem> withRegex = withRegex(".*" + consoleType
|
||||||
+ ".*");
|
+ ".*");
|
||||||
bot.shell("C/C++ - Eclipse Platform").activate();
|
focusMainShell();
|
||||||
b.menuItem(withRegex).click();
|
b.menuItem(withRegex).click();
|
||||||
try {
|
try {
|
||||||
b.pressShortcut(KeyStroke.getInstance("ESC"));
|
b.pressShortcut(KeyStroke.getInstance("ESC"));
|
||||||
|
@ -315,6 +306,24 @@ public abstract class AbstractTest {
|
||||||
return view;
|
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
|
@After
|
||||||
public void cleanUp() {
|
public void cleanUp() {
|
||||||
exitProjectFolder();
|
exitProjectFolder();
|
||||||
|
|
|
@ -162,7 +162,7 @@ public class TestEnvironmentVars extends AbstractTest {
|
||||||
// the script
|
// the script
|
||||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
||||||
"Reconfigure Project");
|
"Reconfigure Project");
|
||||||
bot.shell("C/C++ - Eclipse Platform").activate();
|
focusMainShell();
|
||||||
bot.sleep(3000);
|
bot.sleep(3000);
|
||||||
SWTBotView consoleView = bot.viewByPartName("Console");
|
SWTBotView consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
|
|
Loading…
Add table
Reference in a new issue