Skip to main content
summaryrefslogtreecommitdiffstats
path: root/gcov
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2014-04-16 19:10:21 +0000
committerAlexander Kurtakov2014-04-22 14:24:11 +0000
commit3aaff940b63d184248efa2d4af8a4e0313b18845 (patch)
tree5c7eb74709783aa16fdc99e9da0892b6e4902905 /gcov
parent6b9c08235c58e071f72b849a43aab2184fbf13bd (diff)
downloadorg.eclipse.linuxtools-3aaff940b63d184248efa2d4af8a4e0313b18845.tar.gz
org.eclipse.linuxtools-3aaff940b63d184248efa2d4af8a4e0313b18845.tar.xz
org.eclipse.linuxtools-3aaff940b63d184248efa2d4af8a4e0313b18845.zip
Linuxtools: Circumvent M7 SWTBot test problems.
Where possible, use alternatives to ContextMenuHelper when the workbench's active selection is needed (EBZ #433014). Also perform minor cleanup on some tests. Change-Id: I23834cdc4b89df87b6e6d5666bce8b6f646a6cc0 Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/25236 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'gcov')
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/internal/gcov/test/GcovTest.java57
1 files changed, 53 insertions, 4 deletions
diff --git a/gcov/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/internal/gcov/test/GcovTest.java b/gcov/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/internal/gcov/test/GcovTest.java
index 41757266eb..b423f3278d 100644
--- a/gcov/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/internal/gcov/test/GcovTest.java
+++ b/gcov/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/internal/gcov/test/GcovTest.java
@@ -2,6 +2,8 @@ package org.eclipse.linuxtools.internal.gcov.test;
import static org.eclipse.swtbot.swt.finder.finders.ContextMenuHelper.contextMenu;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withText;
+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.assertNotEquals;
import static org.junit.Assert.assertTrue;
@@ -31,6 +33,7 @@ import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
@@ -46,6 +49,7 @@ import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.hamcrest.Matcher;
+import org.junit.After;
import org.osgi.framework.FrameworkUtil;
public abstract class GcovTest {
@@ -161,14 +165,62 @@ public abstract class GcovTest {
return bot;
}
+ @After
+ public void cleanUp() {
+ SWTWorkbenchBot bot = new SWTWorkbenchBot();
+ SWTBotShell[] shells = bot.shells();
+ for (final SWTBotShell shell : shells) {
+ String shellTitle = shell.getText();
+ if (shellTitle.length() > 0
+ && !shellTitle.startsWith("SystemTap IDE")
+ && !shellTitle.startsWith("Quick Access")) {
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
+ public void run() {
+ if (shell.widget.getParent() != null) {
+ shell.close();
+ }
+ }
+ });
+ }
+ }
+ bot.closeAllEditors();
+ }
+
public static void cleanup(SWTWorkbenchBot bot) {
// clear project explorer
+ exitProjectFolder(bot);
+ projectExplorer.setFocus();
SWTBotTree treeBot = projectExplorer.bot().tree();
for (SWTBotTreeItem treeItem : treeBot.getAllItems()) {
removeTreeItem(bot, treeItem);
}
}
+ /**
+ * Enter the project folder so as to avoid expanding trees later
+ */
+ private static SWTBotView enterProjectFolder(SWTWorkbenchBot bot, String projectName) {
+ projectExplorer.bot().tree().select(projectName).
+ contextMenu("Go Into").click();
+ bot.waitUntil(waitForWidget(WidgetMatcherFactory.withText(
+ projectName), projectExplorer.getWidget()));
+ return projectExplorer;
+ }
+
+ /**
+ * Exit from the project tree.
+ */
+ private static void exitProjectFolder(SWTWorkbenchBot bot) {
+ try {
+ SWTBotToolbarButton forwardButton = projectExplorer.toolbarPushButton("Forward");
+ projectExplorer.toolbarPushButton("Back to Workspace").click();
+ bot.waitUntil(widgetIsEnabled(forwardButton));
+ } catch (WidgetNotFoundException e) {
+ // Already exited from project folder
+ }
+ }
+
public static void createProject(SWTWorkbenchBot bot, String projectName, String projectType) {
mainShell.activate();
SWTBotMenu fileMenu = bot.menu("File");
@@ -348,7 +400,7 @@ public abstract class GcovTest {
// We need to select the binary, but in the tree, it may have additional info appended to the
// name such as [x86_64/le]. So, we look at all nodes of the project and look for the one that
// starts with our binary file name. We can then select the node.
- projectExplorer.bot().tree().select(projectName).contextMenu("Go Into").click();
+ enterProjectFolder(bot, projectName);
bot.waitUntil(Conditions.waitForWidget(withText(projectName), projectExplorer.getWidget()));
SWTBotTreeItem[] nodes = treeBot.getAllItems();
@@ -383,9 +435,6 @@ public abstract class GcovTest {
SWTBotView botView = bot.viewByTitle("gcov");
botView.close();
- SWTBotToolbarButton forwardButton = projectExplorer.toolbarPushButton("Forward");
- projectExplorer.toolbarPushButton("Back to Workspace").click();
- bot.waitUntil(Conditions.widgetIsEnabled(forwardButton));
}
private static void dumpCSV(SWTWorkbenchBot bot, SWTBotView botView, String projectName, String type,

Back to the top