tmf: Fix flaky ImportAndReadSmokeTest test
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tue, 7 Jul 2015 23:47:55 +0000 (19:47 -0400)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Wed, 8 Jul 2015 15:06:44 +0000 (11:06 -0400)
In this test, it was possible for SWTBotUtils.openEditor to timeout
because it would not find the right Tree and it would wait for a
TreeItem forever. Instead, we can use the SWTBot from the view to narrow
down where the Tree is searched and it returns the right one. I saw this
test being flaky on Windows.

Change-Id: I44e98b6e88d795fd8b0d38b75ad0506e849af4b5
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/51535
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotUtils.java

index a3e34dde340fa44f8fc37a88f24e124b760d8a91..b9c5bf2fc0e9dbf04b5eddc52d8ae166abb96fc9 100644 (file)
@@ -336,20 +336,21 @@ public final class SWTBotUtils {
      * @return TmfEventsEditor the opened editor
      */
     public static TmfEventsEditor openEditor(SWTWorkbenchBot bot, String projectName, IPath elementPath) {
      * @return TmfEventsEditor the opened editor
      */
     public static TmfEventsEditor openEditor(SWTWorkbenchBot bot, String projectName, IPath elementPath) {
-        final SWTBotView projectExplorerBot = bot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
-        projectExplorerBot.setFocus();
+        final SWTBotView projectExplorerView = bot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
+        projectExplorerView.setFocus();
+        SWTBot projectExplorerBot = projectExplorerView.bot();
 
 
-        final SWTBotTree tree = bot.tree();
-        bot.waitUntil(ConditionHelpers.IsTreeNodeAvailable(projectName, tree));
+        final SWTBotTree tree = projectExplorerBot.tree();
+        projectExplorerBot.waitUntil(ConditionHelpers.IsTreeNodeAvailable(projectName, tree));
         final SWTBotTreeItem treeItem = tree.getTreeItem(projectName);
         treeItem.expand();
 
         final SWTBotTreeItem treeItem = tree.getTreeItem(projectName);
         treeItem.expand();
 
-        SWTBotTreeItem tracesNode = getTraceProjectItem(bot, treeItem, TmfTracesFolder.TRACES_FOLDER_NAME);
+        SWTBotTreeItem tracesNode = getTraceProjectItem(projectExplorerBot, treeItem, TmfTracesFolder.TRACES_FOLDER_NAME);
         tracesNode.expand();
 
         SWTBotTreeItem currentItem = tracesNode;
         for (String segment : elementPath.segments()) {
         tracesNode.expand();
 
         SWTBotTreeItem currentItem = tracesNode;
         for (String segment : elementPath.segments()) {
-            currentItem = getTraceProjectItem(bot, currentItem, segment);
+            currentItem = getTraceProjectItem(projectExplorerBot, currentItem, segment);
             currentItem.select();
             currentItem.doubleClick();
         }
             currentItem.select();
             currentItem.doubleClick();
         }
@@ -372,7 +373,7 @@ public final class SWTBotUtils {
      *            the desired child element name (without suffix)
      * @return the a {@link SWTBotTreeItem} with the specified name
      */
      *            the desired child element name (without suffix)
      * @return the a {@link SWTBotTreeItem} with the specified name
      */
-    public static SWTBotTreeItem getTraceProjectItem(SWTWorkbenchBot bot, final SWTBotTreeItem parentItem, final String name) {
+    public static SWTBotTreeItem getTraceProjectItem(SWTBot bot, final SWTBotTreeItem parentItem, final String name) {
         ProjectElementHasChild condition = new ProjectElementHasChild(parentItem, name);
         bot.waitUntil(condition);
         return condition.getItem();
         ProjectElementHasChild condition = new ProjectElementHasChild(parentItem, name);
         bot.waitUntil(condition);
         return condition.getItem();
This page took 0.026821 seconds and 5 git commands to generate.