import java.util.Arrays;
import java.util.List;
+import java.util.regex.Pattern;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
import org.eclipse.tracecompass.tmf.ui.editors.TmfEventsEditor;
+import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfXYChartViewer;
import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView;
import org.eclipse.ui.IEditorReference;
import org.hamcrest.Matcher;
+import org.swtchart.Chart;
/**
* Is a tree node available
@Override
public String getFailureMessage() {
- return NLS.bind("No child of table {0} found with text '{1}'.", table, name);
+ return NLS.bind("No child of table {0} found with text ''{1}''.", table, name);
}
};
}
@Override
public String getFailureMessage() {
- return NLS.bind("No child of tree item {0} found with text '{1}'. Child items: {2}",
+ return NLS.bind("No child of tree item {0} found with text ''{1}''. Child items: {2}",
new String[] { treeItem.toString(), name, Arrays.toString(treeItem.getItems()) });
}
};
@Override
public String getFailureMessage() {
- return NLS.bind("Child of tree item {0} found with text '{1}' not removed. Child items: {2}",
+ return NLS.bind("Child of tree item {0} found with text ''{1}'' not removed. Child items: {2}",
new String[] { treeItem.toString(), String.valueOf(length), Arrays.toString(treeItem.getItems()) });
}
};
}
return false;
}
+
+ @Override
+ public String getFailureMessage() {
+ String cell = table.cell(row, column);
+ if (cell == null) {
+ return NLS.bind("Cell absent, expected: {0}", content);
+ }
+ return NLS.bind("Cell content: {0} expected: {1}", cell, content);
+ }
};
}
fParentItem = parentItem;
fName = name;
/* Project element labels may have count suffix */
- fRegex = name + "(\\s\\[(\\d)+\\])?";
+ fRegex = Pattern.quote(name) + "(\\s\\[(\\d)+\\])?";
}
@Override
return new TimeGraphIsReadyCondition(view, selectionRange, visibleTime);
}
+ private static class XYViewerIsReadyCondition extends DefaultCondition {
+
+ private TmfXYChartViewer fViewer;
+ private String fFailureMessage;
+
+ private XYViewerIsReadyCondition(TmfXYChartViewer view) {
+ fViewer = view;
+ }
+
+ @Override
+ public boolean test() throws Exception {
+
+ if (fViewer.isDirty()) {
+ fFailureMessage = "Time graph is dirty";
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return fFailureMessage;
+ }
+ }
+
+ /**
+ *
+ * Wait until the XY chart viewer is ready. The XY chart viewer is
+ * considered ready when it is not updating.
+ *
+ * @param viewer
+ * the XY chart viewer
+ * @return ICondition for verification
+ */
+ public static ICondition xyViewerIsReadyCondition(TmfXYChartViewer viewer) {
+ return new XYViewerIsReadyCondition(viewer);
+ }
+
private static class NumberOfEventsCondition extends DefaultCondition {
private ITmfTrace fTrace;
return fEditor;
}
}
+
+ private static class NumberOfSeries extends DefaultCondition {
+ private String fFailureMessage;
+ private Chart fChart;
+ private final int fNumberOfSeries;
+
+ public NumberOfSeries(Chart chart, int numberOfSeries) {
+ fChart = chart;
+ fNumberOfSeries = numberOfSeries;
+ }
+
+ @Override
+ public boolean test() throws Exception {
+ int length = fChart.getSeriesSet().getSeries().length;
+ if (length != fNumberOfSeries){
+ fFailureMessage = "Chart did not contain the expected number series. Actual " + length + ", expected " + fNumberOfSeries;
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return fFailureMessage;
+ }
+ }
+
+ /**
+ * Wait until the chart has the specified number of series.
+ *
+ * @param chart
+ * the chart
+ * @param numberOfSeries
+ * the number of expected series
+ *
+ * @return ICondition for verification
+ */
+ 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() });
+ }
+ }
}