releng: Add SWTBot integration tests for import wizard
[deliverable/tracecompass.git] / ctf / org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests / src / org / eclipse / tracecompass / tmf / ctf / ui / swtbot / tests / SWTBotImportWizardUtils.java
index fcdddf7ccca242f948e8f8b0dde14ad5e73456e5..14ae8c17f67313447cae766f17274f1566871d52 100644 (file)
@@ -10,6 +10,7 @@
 package org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests;
 
 import java.io.File;
+import java.util.Arrays;
 
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
@@ -75,6 +76,46 @@ public final class SWTBotImportWizardUtils {
         text.setFocus();
     }
 
+    /**
+     * While in the import wizard, select an item in the file selection control.
+     * The item can be a folder in the left tree or a file in the right table.
+     * The item will be checked.
+     *
+     * @param bot
+     *            the SWTBot
+     * @param treePath
+     *            the path to the item, ending with a file or folder
+     */
+    public static void selectItem(SWTBot bot, String... treePath) {
+        SWTBotTree tree = bot.tree();
+        bot.waitUntil(Conditions.widgetIsEnabled(tree));
+        if (treePath.length == 0) {
+            return;
+        }
+        if (treePath.length == 1) {
+            SWTBotTreeItem rootNode = SWTBotUtils.getTreeItem(bot, tree, treePath);
+            rootNode.select();
+            rootNode.check();
+            return;
+        }
+        String[] parentPath = Arrays.copyOf(treePath, treePath.length - 1);
+        String itemName = treePath[treePath.length - 1];
+        SWTBotTreeItem folderNode = SWTBotUtils.getTreeItem(bot, tree, parentPath);
+        folderNode.expand();
+        if (folderNode.getNodes().contains(itemName)) {
+            folderNode = folderNode.getNode(itemName);
+            folderNode.select();
+            folderNode.check();
+        } else {
+            folderNode.select();
+            SWTBotTable fileTable = bot.table();
+            bot.waitUntil(Conditions.widgetIsEnabled(fileTable));
+            bot.waitUntil(ConditionHelpers.isTableItemAvailable(itemName, fileTable));
+            SWTBotTableItem tableItem = fileTable.getTableItem(itemName);
+            tableItem.check();
+        }
+    }
+
     /**
      * While in the import wizard, select a folder in the file selection tree.
      *
This page took 0.024596 seconds and 5 git commands to generate.