Search in sources :

Example 1 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class CounterDataProvider method addTreeViewerEntries.

/**
 * Recursively add all child entries of a parent branch from the state system.
 */
private void addTreeViewerEntries(ITmfStateSystem ss, long parentId, int quark, List<TmfTreeDataModel> entries) {
    for (int childQuark : ss.getSubAttributes(quark, false)) {
        long id = getId(childQuark);
        TmfTreeDataModel childBranch = new TmfTreeDataModel(id, parentId, Collections.singletonList(ss.getAttributeName(childQuark)));
        entries.add(childBranch);
        addTreeViewerEntries(ss, id, childQuark, entries);
    }
}
Also used : TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)

Example 2 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class InputOutputDataProviderTest method testDiskActivity.

/**
 * Test the data provider
 */
@Test
public void testDiskActivity() {
    DisksIODataProvider provider = getProvider();
    Collection<@NonNull DiskActivity> diskActivity = fTestCase.getDiskActivity();
    for (DiskActivity test : diskActivity) {
        Map<@NonNull String, @NonNull Object> parameters = test.getTimeQuery();
        TmfModelResponse<@NonNull TmfTreeModel<@NonNull TmfTreeDataModel>> response = provider.fetchTree(parameters, PROGRESS_MONITOR);
        assertEquals(ITmfResponse.Status.COMPLETED, response.getStatus());
        TmfTreeModel<@NonNull TmfTreeDataModel> model = response.getModel();
        assertNotNull(model);
        parameters = test.getTimeQueryForModel(model);
        TmfModelResponse<@NonNull ITmfXyModel> yResponse = provider.fetchXY(parameters, PROGRESS_MONITOR);
        assertEquals(ITmfResponse.Status.COMPLETED, yResponse.getStatus());
        ITmfXyModel yModel = yResponse.getModel();
        assertNotNull(yModel);
        Collection<@NonNull ISeriesModel> data = yModel.getSeriesData();
        assertEquals(1, data.size());
        ISeriesModel ySeries = data.iterator().next();
        double[] expected = test.getActivity();
        double[] actual = ySeries.getData();
        for (int i = 0; i < expected.length; i++) {
            assertTrue(String.format("No actual value at position %d for %s", i, test), actual.length > i);
            assertEquals(String.format("Value at position %d for %s", i, test), expected[i], actual[i], 0.001);
        }
        assertEquals(String.format("More values than expected for %s", test), expected.length, actual.length);
    }
}
Also used : ISeriesModel(org.eclipse.tracecompass.tmf.core.model.xy.ISeriesModel) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) DisksIODataProvider(org.eclipse.tracecompass.internal.analysis.os.linux.core.inputoutput.DisksIODataProvider) DiskActivity(org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.inputoutput.IoTestCase.DiskActivity) NonNull(org.eclipse.jdt.annotation.NonNull) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) ITmfXyModel(org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel) Test(org.junit.Test)

Example 3 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class TmfTreeDataModelTest method testCompositeTree.

/**
 * Test {@link TmfTreeCompositeDataProvider}
 */
@Test
public void testCompositeTree() {
    List<DummyDataProvider> ddps = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        ddps.add(new DummyDataProvider(i));
    }
    TmfTreeCompositeDataProvider<@NonNull TmfTreeDataModel, @NonNull DummyDataProvider> composite = new TmfTreeCompositeDataProvider<>(ddps, "composite-dummy");
    assertNotNull(composite);
    NullProgressMonitor monitor = new NullProgressMonitor();
    TmfModelResponse<@NonNull TmfTreeModel<@NonNull TmfTreeDataModel>> tree = composite.fetchTree(Collections.emptyMap(), monitor);
    TmfTreeModel<@NonNull TmfTreeDataModel> model = tree.getModel();
    assertNotNull(model);
    assertEquals(Arrays.asList("header"), model.getHeaders());
    assertEquals(3, model.getEntries().size());
    // AnnotationCategories
    TmfModelResponse<@NonNull AnnotationCategoriesModel> returnVal = composite.fetchAnnotationCategories(Collections.emptyMap(), monitor);
    AnnotationCategoriesModel categoryModel = returnVal.getModel();
    assertNotNull(categoryModel);
    assertEquals(Arrays.asList("common", "0", "1", "2"), categoryModel.getAnnotationCategories());
    // Annotations
    TmfModelResponse<@NonNull AnnotationModel> annotations = composite.fetchAnnotations(Collections.emptyMap(), monitor);
    AnnotationModel annotationsModel = annotations.getModel();
    assertNotNull(annotationsModel);
    Collection<@NonNull Annotation> collection = annotationsModel.getAnnotations().get("test");
    assertNotNull(collection);
    assertEquals(6, collection.size());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) AnnotationCategoriesModel(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationCategoriesModel) ArrayList(java.util.ArrayList) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) NonNull(org.eclipse.jdt.annotation.NonNull) AnnotationModel(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationModel) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) TmfTreeCompositeDataProvider(org.eclipse.tracecompass.internal.tmf.core.model.tree.TmfTreeCompositeDataProvider) Test(org.junit.Test)

Example 4 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class TmfTreeDataModelTest method testEqualsSymmetry.

/**
 * Run the {@link TmfTreeDataModel#equals} method test.
 */
@Test
public void testEqualsSymmetry() {
    TmfTreeDataModel model0 = createModel(0);
    TmfTreeDataModel model1 = createModel(1);
    assertTrue(EQUALS, model0.equals(fModel0));
    assertTrue(EQUALS, fModel0.equals(model0));
    assertTrue(EQUALS, model1.equals(fModel1));
    assertTrue(EQUALS, fModel1.equals(model1));
}
Also used : TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) Test(org.junit.Test)

Example 5 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class TmfTreeDataModelTest method testToString.

/**
 * Test {@link TmfTreeDataModel#toString()}
 */
@Test
public void testToString() {
    assertEquals(TO_STRING, "<name=[label1, label2, label3] id=0 parentId=-1 style=null hasRowModel=true>", fModel0.toString());
    assertEquals(TO_STRING, "<name=[label4, label5, label6, label7] id=1 parentId=0 style=Style [1, {}] hasRowModel=false>", fModel1.toString());
    TmfTreeDataModel model2 = createModel(2);
    assertEquals(TO_STRING, "<name=[Name] id=2 parentId=-1 style=null hasRowModel=true>", model2.toString());
}
Also used : TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) Test(org.junit.Test)

Aggregations

TmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)21 Test (org.junit.Test)9 TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)8 ArrayList (java.util.ArrayList)5 NonNull (org.eclipse.jdt.annotation.NonNull)4 ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)4 HashMap (java.util.HashMap)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 Nullable (org.eclipse.jdt.annotation.Nullable)3 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)3 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)3 Map (java.util.Map)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)2 OutputElementStyle (org.eclipse.tracecompass.tmf.core.model.OutputElementStyle)2 TimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)2 ITmfTreeXYDataProvider (org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider)2 ITmfXyModel (org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel)2 ITmfTreeViewerEntry (org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry)2 TmfGenericTreeEntry (org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry)2