Fix SWTBotEclipseEditorTest
Don't assume that the active shell is the active workbench window shell.
Change-Id: I2d923a50c73e92ddb92228c148f54af71093b242
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
diff --git a/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/widgets/helpers/NewJavaClass.java b/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/widgets/helpers/NewJavaClass.java
index 9718c00..1df4859 100644
--- a/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/widgets/helpers/NewJavaClass.java
+++ b/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/widgets/helpers/NewJavaClass.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2015 Ketan Padegaonkar and others.
+ * Copyright (c) 2008, 2019 Ketan Padegaonkar and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -27,6 +27,8 @@
private SWTWorkbenchBot bot = new SWTWorkbenchBot();
public void createClass(String packageName, String className) {
+ bot.shell().activate();
+
if (!bot.activePerspective().getLabel().equals("Java")) {
SWTBotMenu windowMenu = bot.menu("Window");
SWTBotMenu perspectiveMenu = windowMenu.menu("Open Perspective");
@@ -36,6 +38,7 @@
}
}
bot.menu("File").menu("New").menu("Class").click();
+
SWTBotShell shell = bot.shell("New Java Class");
shell.activate();
bot.textWithLabel("Package:").setText(packageName);
@@ -43,5 +46,7 @@
bot.button("Finish").click();
bot.waitUntil(Conditions.shellCloses(shell));
+
+ bot.shell().activate();
}
}
diff --git a/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/widgets/helpers/NewJavaProject.java b/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/widgets/helpers/NewJavaProject.java
index 8e0584d..91f401c 100644
--- a/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/widgets/helpers/NewJavaProject.java
+++ b/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/widgets/helpers/NewJavaProject.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2015 Ketan Padegaonkar and others.
+ * Copyright (c) 2008, 2019 Ketan Padegaonkar and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -28,6 +28,8 @@
private SWTWorkbenchBot bot = new SWTWorkbenchBot();
public void createProject(String projectName) throws Exception {
+ bot.shell().activate();
+
if (!bot.activePerspective().getLabel().equals("Java")) {
// In Mars "Open Perspective" is nested in "Perspective", so use this
// method to recursively find "Open Perspective" and don't assume it is
@@ -39,7 +41,6 @@
}
}
bot.menu("File").menu("New").menu("Java Project").click();
-
SWTBotShell shell = bot.shell("New Java Project");
shell.activate();
@@ -48,6 +49,7 @@
bot.waitUntil(Conditions.shellCloses(shell));
+ bot.shell().activate();
}
}