import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.tracecompass.internal.tmf.core.Activator;
import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimePreferencesConstants;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimePreferences;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers.SWTBotTestCondition;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
+import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils.Resolution;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils.TimeFormat;
private static final long LTTNG_CONSUMER_BIRTHTIME = 1361214078963717040L;
private static final String LTTNG_CONSUMER_TID = "4034";
+ private static final @NonNull TmfTimestamp TRACE_START_TIME = new TmfTimestamp(1361214078963711320L, ITmfTimestamp.NANOSECOND_SCALE);
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
*/
@Test
public void testColumnSorting() {
+ fBot.waitUntil(ConditionHelpers.timeGraphIsReadyCondition((AbstractTimeGraphView) fViewBot.getViewReference().getPart(false), new TmfTimeRange(TRACE_START_TIME, TRACE_START_TIME), TRACE_START_TIME));
+
// Create a known state
applyFilter();
final SWTBotTree tree = fViewBot.bot().tree();
/* change window range to 1 ms */
TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(1000000L, ITmfTimestamp.NANOSECOND_SCALE));
TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
- fBot.waitUntil(ConditionHelpers.windowRange(range));
+ timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
SWTBotToolbarButton filterButton = fViewBot.toolbarButton("Show View Filters");
filterButton.click();
private @NonNull TmfTimeRange fSelectionRange;
private @NonNull ITmfTimestamp fVisibleTime;
private AbstractTimeGraphView fView;
+ private String fFailureMessage;
private TimeGraphIsReadyCondition(AbstractTimeGraphView view, @NonNull TmfTimeRange selectionRange, @NonNull ITmfTimestamp visibleTime) {
fView = view;
@Override
public boolean test() throws Exception {
- if (!ConditionHelpers.selectionRange(fSelectionRange).test()) {
+ ICondition selectionRangeCondition = ConditionHelpers.selectionRange(fSelectionRange);
+ if (!selectionRangeCondition.test()) {
+ fFailureMessage = selectionRangeCondition.getFailureMessage();
return false;
}
- if (!TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(fVisibleTime)) {
+ @NonNull TmfTimeRange curWindowRange = TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange();
+ if (!curWindowRange.contains(fVisibleTime)) {
+ fFailureMessage = "Current window range " + curWindowRange + " does not contain " + fVisibleTime;
return false;
}
- return !fView.isDirty();
+
+ if (fView.isDirty()) {
+ fFailureMessage = "Time graph is dirty";
+ return false;
+
+ }
+ return true;
}
@Override
public String getFailureMessage() {
- return "Time graph is not ready";
+ return fFailureMessage;
}
}
if (fTimeGraphWrapper.isDisposed()) {
return;
}
+ fDirty.incrementAndGet();
+
boolean hasEntries = false;
synchronized (fEntryListMap) {
fEntryList = fEntryListMap.get(fTrace);
if (!zoomThread) {
startZoomThread(startTime, endTime);
}
-
+ fDirty.decrementAndGet();
}
});
}
* @since 2.0
*/
protected final void startZoomThread(long startTime, long endTime) {
+ long clampedStartTime = Math.min(Math.max(startTime, fStartTime), fEndTime);
+ long clampedEndTime = Math.max(Math.min(endTime, fEndTime), fStartTime);
fDirty.incrementAndGet();
boolean restart = false;
if (fZoomThread != null) {
fZoomThread.cancel();
- if (fZoomThread.fZoomStartTime == startTime && fZoomThread.fZoomEndTime == endTime) {
+ if (fZoomThread.fZoomStartTime == clampedStartTime && fZoomThread.fZoomEndTime == clampedEndTime) {
restart = true;
}
}
- long resolution = Math.max(1, (endTime - startTime) / fDisplayWidth);
- fZoomThread = createZoomThread(startTime, endTime, resolution, restart);
+ long resolution = Math.max(1, (clampedEndTime - clampedStartTime) / fDisplayWidth);
+ fZoomThread = createZoomThread(clampedStartTime, clampedEndTime, resolution, restart);
if (fZoomThread != null) {
fZoomThread.start();
} else {
* Returns whether or not the time graph view is dirty. The time graph view
* is considered dirty if it has yet to completely update its model.
*
+ * This method is meant to be used by tests in order to know when it is safe
+ * to proceed.
+ *
+ * Note: If a trace is smaller than the initial window range (see
+ * {@link ITmfTrace#getInitialRangeOffset}) this method will return true
+ * forever.
+ *
* @return true if the time graph view has yet to completely update its
* model, false otherwise
* @since 2.0
*/
public boolean isDirty() {
- if (fZoomThread == null) {
+ if (fTrace == null) {
return false;
}
- return fDirty.get() != 0 || fZoomThread.getZoomStartTime() != fTimeGraphWrapper.getTimeGraphViewer().getTime0() || fZoomThread.getZoomEndTime() != fTimeGraphWrapper.getTimeGraphViewer().getTime1();
+
+ TmfTraceContext ctx = TmfTraceManager.getInstance().getCurrentTraceContext();
+ long startTime = ctx.getWindowRange().getStartTime().toNanos();
+ long endTime = ctx.getWindowRange().getEndTime().toNanos();
+
+ // If the time graph control hasn't updated all the way to the end of
+ // the window range then it's dirty. A refresh should happen later.
+ if (fTimeGraphWrapper.getTimeGraphViewer().getTime0() != startTime || fTimeGraphWrapper.getTimeGraphViewer().getTime1() != endTime) {
+ return true;
+ }
+
+ if (fZoomThread == null) {
+ // The zoom thread is null but we might be just about to create it (refresh called).
+ return fDirty.get() != 0;
+ }
+ // Dirty if the zoom thread is not done or if it hasn't zoomed all the
+ // way to the end of the window range. In the latter case, there should be
+ // a subsequent zoom thread that will be triggered.
+ return fDirty.get() != 0 || fZoomThread.getZoomStartTime() != startTime || fZoomThread.getZoomEndTime() != endTime;
}
private void createColumnSelectionListener(TreeViewer treeViewer) {