Skip to content

Commit

Permalink
tmf: Set default entries in histogram data provider
Browse files Browse the repository at this point in the history
Bug 581325

[Added] Set default entries in histogram data provider

Change-Id: I331897b9fa79883641fe25bfa6b1012dc3ad4643
Signed-off-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/199324
Tested-by: Marco Miller <marco.miller@ericsson.com>
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Reviewed-by: Marco Miller <marco.miller@ericsson.com>
  • Loading branch information
bhufmann committed Jan 13, 2023
1 parent fb2bad5 commit 83a1837
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Expand Up @@ -31,6 +31,7 @@
import org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel;
import org.eclipse.tracecompass.tmf.core.model.xy.ISeriesModel;
import org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel;
import org.eclipse.tracecompass.tmf.core.model.xy.TmfXyTreeDataModel;
import org.eclipse.tracecompass.tmf.core.response.ITmfResponse;
import org.eclipse.tracecompass.tmf.core.response.TmfModelResponse;
import org.eclipse.tracecompass.tmf.core.statistics.TmfStatisticsModule;
Expand All @@ -53,7 +54,9 @@ public class HistogramDataProviderTest {
private static final long START = 1376592664828559410L;
private static final long END = 1376592668452869400L;

private static final List<String> EXPECTED_FULL_PATHS = ImmutableList.of("hello-lost", "hello-lost/Total", "hello-lost/Lost");
private static final @NonNull String TRACE_NAME = "hello-lost";

private static final List<String> EXPECTED_FULL_PATHS = ImmutableList.of(TRACE_NAME, TRACE_NAME + "/Total", TRACE_NAME + "/Lost");
private static final long @NonNull [] EXPECTED_COMMON_XDATA = new long[] {
1376592664828559410l, 1376592664865168602l, 1376592664901777794l, 1376592664938386985l, 1376592664974996177l, 1376592665011605369l, 1376592665048214561l, 1376592665084823753l, 1376592665121432945l, 1376592665158042136l,
1376592665194651328l, 1376592665231260520l, 1376592665267869712l, 1376592665304478904l, 1376592665341088095l, 1376592665377697287l, 1376592665414306479l, 1376592665450915671l, 1376592665487524863l, 1376592665524134055l,
Expand Down Expand Up @@ -107,6 +110,13 @@ public void testHelloLost() throws TmfAnalysisException {
assertNotNull(treeModel);
assertEquals(EXPECTED_FULL_PATHS, getFullPaths(treeModel.getEntries()));

for (TmfTreeDataModel entry : treeModel.getEntries()) {
if (!entry.getName().equals(TRACE_NAME)) {
assertTrue(entry instanceof TmfXyTreeDataModel);
assertTrue(((TmfXyTreeDataModel) entry).isDefault());
}
}

List<Long> ids = Lists.transform(treeModel.getEntries(), TmfTreeDataModel::getId);
SelectionTimeQueryFilter selectionFilter = new SelectionTimeQueryFilter(START, END, 100, ids);
TmfModelResponse<@NonNull ITmfXyModel> xyResponse = provider.fetchXY(FetchParametersUtils.selectionTimeQueryToMap(selectionFilter), null);
Expand Down
Expand Up @@ -39,6 +39,7 @@
import org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider;
import org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel;
import org.eclipse.tracecompass.tmf.core.model.xy.IYModel;
import org.eclipse.tracecompass.tmf.core.model.xy.TmfXyTreeDataModel;
import org.eclipse.tracecompass.tmf.core.response.ITmfResponse;
import org.eclipse.tracecompass.tmf.core.response.TmfModelResponse;
import org.eclipse.tracecompass.tmf.core.statistics.ITmfStatistics;
Expand Down Expand Up @@ -95,10 +96,10 @@ public TmfModelResponse<TmfTreeModel<TmfTreeDataModel>> fetchTree(Map<String, Ob
fModule.waitForInitialization();
Builder<TmfTreeDataModel> builder = ImmutableList.builder();
builder.add(new TmfTreeDataModel(fTraceId, -1, Collections.singletonList(getTrace().getName())));
builder.add(new TmfTreeDataModel(fTotalId, fTraceId, Collections.singletonList(Objects.requireNonNull(Messages.HistogramDataProvider_Total))));
builder.add(new TmfXyTreeDataModel(fTotalId, fTraceId, Collections.singletonList(Objects.requireNonNull(Messages.HistogramDataProvider_Total)), true, null, true));
ITmfStateSystem eventsSs = Objects.requireNonNull(fModule.getStateSystem(TmfStatisticsEventTypesModule.ID));
if (eventsSs.optQuarkAbsolute(Attributes.LOST_EVENTS) != ITmfStateSystem.INVALID_ATTRIBUTE) {
builder.add(new TmfTreeDataModel(fLostId, fTraceId, Collections.singletonList(Objects.requireNonNull(Messages.HistogramDataProvider_Lost))));
builder.add(new TmfXyTreeDataModel(fLostId, fTraceId, Collections.singletonList(Objects.requireNonNull(Messages.HistogramDataProvider_Lost)), true, null, true));
}
if (eventsSs.waitUntilBuilt(0)) {
TmfModelResponse<TmfTreeModel<TmfTreeDataModel>> response = new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), builder.build()), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
Expand Down

0 comments on commit 83a1837

Please sign in to comment.