private static final String PROJECT_NAME = "test";
private static final String TRACE_TYPE = "org.eclipse.linuxtools.lttng2.kernel.tracetype";
+ private static final String TRACE_NAME = "bug446190";
/** The Log4j logger instance. */
private static final Logger fLogger = Logger.getRootLogger();
*/
private static void openView(final String viewTitle) {
SWTBotTreeItem treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);
- treeItem = treeItem.expand();
- treeItem = treeItem.getNode(0).expand();
- treeItem = treeItem.expandNode("Views", "XML system call analysis");
- treeItem = treeItem.getNode(viewTitle);
+ treeItem = SWTBotUtils.getTreeItem(fBot, treeItem, TRACE_NAME, "Views", "XML system call analysis", viewTitle);
+ treeItem.select();
treeItem.doubleClick();
- SWTBotUtils.waitForJobs();
}
/**
public static ICondition numberOfSeries(Chart chart, int numberOfSeries) {
return new NumberOfSeries(chart, numberOfSeries);
}
+
+ /**
+ * Condition to check if the tree item has children
+ *
+ * @param treeItem
+ * the tree item that should have children
+ * @return ICondition for verification
+ */
+ public static ICondition treeItemHasChildren(SWTBotTreeItem treeItem) {
+ return new TreeItemHasChildren(treeItem);
+ }
+
+ private static final class TreeItemHasChildren extends DefaultCondition {
+ private SWTBotTreeItem fTreeItem;
+
+ public TreeItemHasChildren(SWTBotTreeItem treeItem) {
+ fTreeItem = treeItem;
+ }
+
+ @Override
+ public boolean test() throws Exception {
+ return fTreeItem.getItems().length > 0;
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return NLS.bind("No child of tree item {0} found.", new String[] { fTreeItem.toString() });
+ }
+ }
}
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.util.Arrays;
import java.util.List;
import java.util.TimeZone;
import java.util.concurrent.atomic.AtomicBoolean;
bot.waitUntil(ConditionHelpers.IsTreeNodeAvailable(nodeNames[0], tree));
SWTBotTreeItem currentNode = tree.getTreeItem(nodeNames[0]);
- for (int i = 1; i < nodeNames.length; i++) {
+ return getTreeItem(bot, currentNode, Arrays.copyOfRange(nodeNames, 1, nodeNames.length));
+ }
+
+ /**
+ * Get the tree item from a parent tree item at the specified location
+ *
+ * @param bot
+ * the SWTBot
+ * @param treeItem
+ * the treeItem to find the tree item under
+ * @param nodeNames
+ * the path to the tree item, in the form of node names (from
+ * parent to child).
+ * @return the tree item
+ */
+ public static SWTBotTreeItem getTreeItem(SWTBot bot, SWTBotTreeItem treeItem, String... nodeNames) {
+ if (nodeNames.length == 0) {
+ return treeItem;
+ }
+
+ SWTBotTreeItem currentNode = treeItem;
+ for (int i = 0; i < nodeNames.length; i++) {
+ bot.waitUntil(ConditionHelpers.treeItemHasChildren(treeItem));
currentNode.expand();
String nodeName = nodeNames[i];