Search in sources :

Example 6 with Annotation

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation in project tracecompass by tracecompass.

the class PeriodicAnnotationProviderTest method assertAnnotationModelResponse.

private static void assertAnnotationModelResponse(Map<String, List<Annotation>> expectedMap, TmfModelResponse<AnnotationModel> response) {
    assertEquals(Status.COMPLETED, response.getStatus());
    AnnotationModel model = response.getModel();
    assertNotNull(model);
    for (Entry<String, List<Annotation>> entry : expectedMap.entrySet()) {
        String category = entry.getKey();
        List<Annotation> expectedList = entry.getValue();
        Collection<@NonNull Annotation> actualCollection = model.getAnnotations().get(category);
        assertNotNull(actualCollection);
        assertEquals(expectedList.size(), actualCollection.size());
        List<Annotation> actualList = new ArrayList<>(actualCollection);
        for (int i = 0; i < expectedList.size(); i++) {
            Annotation expected = expectedList.get(i);
            Annotation actual = actualList.get(i);
            assertEquals("Time comparison for index " + i + " " + actual.toString(), expected.getTime(), actual.getTime());
            assertEquals("Duration comparison for index " + i + " " + actual.toString(), expected.getDuration(), actual.getDuration());
            assertEquals("EntryId comparison for index " + i + " " + actual.toString(), expected.getEntryId(), actual.getEntryId());
            assertEquals("Label comparison for index " + i + " " + actual.toString(), expected.getLabel(), actual.getLabel());
            assertEquals("Style comparison for index " + i + " " + actual.toString(), expected.getStyle(), actual.getStyle());
        }
    }
}
Also used : AnnotationModel(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationModel) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation)

Example 7 with Annotation

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation in project tracecompass by tracecompass.

the class PeriodicAnnotationProviderTest method testNextPreviousIncluded.

/**
 * Test that previous and next annotations are always included.
 */
@Test
public void testNextPreviousIncluded() {
    IOutputAnnotationProvider provider = new PeriodicAnnotationProvider(CATEGORY, ITimeReference.ZERO, 100L, 0, COLOR, null);
    Map<String, List<Annotation>> expected = ImmutableMap.of(CATEGORY, Arrays.asList(new Annotation(-100L, 0L, -1, "-1", COLOR_STYLE), new Annotation(0L, 0L, -1, "0", COLOR_STYLE), new Annotation(100L, 0L, -1, "1", COLOR_STYLE), new Annotation(200L, 0L, -1, "2", COLOR_STYLE), new Annotation(300L, 0L, -1, "3", COLOR_STYLE), new Annotation(400L, 0L, -1, "4", COLOR_STYLE)));
    Map<String, Object> fetchParameters = ImmutableMap.of(DataProviderParameterUtils.REQUESTED_TIME_KEY, StateSystemUtils.getTimes(0L, 300L, 1));
    assertAnnotationModelResponse(expected, provider.fetchAnnotations(fetchParameters, new NullProgressMonitor()));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PeriodicAnnotationProvider(org.eclipse.tracecompass.internal.tmf.core.annotations.PeriodicAnnotationProvider) IOutputAnnotationProvider(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider) ArrayList(java.util.ArrayList) List(java.util.List) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) Test(org.junit.Test)

Example 8 with Annotation

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation in project tracecompass by tracecompass.

the class PeriodicAnnotationProviderTest method testAlternateShadingAnnotationSource.

/**
 * Test a periodic annotation provider with alternate shading at every period.
 */
@Test
public void testAlternateShadingAnnotationSource() {
    IOutputAnnotationProvider provider = new PeriodicAnnotationProvider(CATEGORY, ITimeReference.ZERO, 100L, 0, EVEN_COLOR, ODD_COLOR);
    Map<String, List<Annotation>> expected = ImmutableMap.of(CATEGORY, Arrays.asList(new Annotation(-100L, 100L, -1, "-1", ODD_COLOR_STYLE), new Annotation(0L, 100L, -1, "0", EVEN_COLOR_STYLE), new Annotation(100L, 100L, -1, "1", ODD_COLOR_STYLE), new Annotation(200L, 100L, -1, "2", EVEN_COLOR_STYLE), new Annotation(300L, 100L, -1, "3", ODD_COLOR_STYLE)));
    Map<String, Object> fetchParameters = ImmutableMap.of(DataProviderParameterUtils.REQUESTED_TIME_KEY, StateSystemUtils.getTimes(50L, 250L, 1));
    assertAnnotationModelResponse(expected, provider.fetchAnnotations(fetchParameters, new NullProgressMonitor()));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PeriodicAnnotationProvider(org.eclipse.tracecompass.internal.tmf.core.annotations.PeriodicAnnotationProvider) IOutputAnnotationProvider(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider) ArrayList(java.util.ArrayList) List(java.util.List) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) Test(org.junit.Test)

Example 9 with Annotation

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation in project tracecompass by tracecompass.

the class PeriodicAnnotationProviderTest method testIsApplicable.

/**
 * Test a periodic annotation provider with a filtering implementation.
 */
@Test
public void testIsApplicable() {
    IOutputAnnotationProvider provider = new PeriodicAnnotationProvider(CATEGORY, ITimeReference.ZERO, 100L, 0, COLOR, null) {

        @Override
        public boolean isApplicable(long index) {
            return (index % 2 == 0);
        }
    };
    Map<String, List<Annotation>> expected = ImmutableMap.of(CATEGORY, Arrays.asList(new Annotation(0L, 0L, -1, "0", COLOR_STYLE), new Annotation(200L, 0L, -1, "2", COLOR_STYLE), new Annotation(400L, 0L, -1, "4", COLOR_STYLE), new Annotation(600L, 0L, -1, "6", COLOR_STYLE), new Annotation(800L, 0L, -1, "8", COLOR_STYLE), new Annotation(1000L, 0L, -1, "10", COLOR_STYLE)));
    Map<String, Object> fetchParameters = ImmutableMap.of(DataProviderParameterUtils.REQUESTED_TIME_KEY, StateSystemUtils.getTimes(0L, 1000L, 1));
    assertAnnotationModelResponse(expected, provider.fetchAnnotations(fetchParameters, new NullProgressMonitor()));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PeriodicAnnotationProvider(org.eclipse.tracecompass.internal.tmf.core.annotations.PeriodicAnnotationProvider) IOutputAnnotationProvider(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider) ArrayList(java.util.ArrayList) List(java.util.List) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) Test(org.junit.Test)

Example 10 with Annotation

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation in project tracecompass by tracecompass.

the class PeriodicAnnotationProviderTest method testFractionalPeriod.

/**
 * Test a periodic annotation provider with a fractional period.
 */
@Test
public void testFractionalPeriod() {
    IOutputAnnotationProvider provider = new PeriodicAnnotationProvider(CATEGORY, ITimeReference.ZERO, (100.0 / 3), 0, EVEN_COLOR, ODD_COLOR);
    Map<String, List<Annotation>> expected = ImmutableMap.of(CATEGORY, Arrays.asList(new Annotation(-33L, 33L, -1, "-1", ODD_COLOR_STYLE), new Annotation(0L, 33L, -1, "0", EVEN_COLOR_STYLE), new Annotation(33L, 34L, -1, "1", ODD_COLOR_STYLE), new Annotation(67L, 33L, -1, "2", EVEN_COLOR_STYLE), new Annotation(100L, 33L, -1, "3", ODD_COLOR_STYLE), new Annotation(133L, 34L, -1, "4", EVEN_COLOR_STYLE)));
    Map<String, Object> fetchParameters = ImmutableMap.of(DataProviderParameterUtils.REQUESTED_TIME_KEY, StateSystemUtils.getTimes(0L, 100L, 1));
    assertAnnotationModelResponse(expected, provider.fetchAnnotations(fetchParameters, new NullProgressMonitor()));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PeriodicAnnotationProvider(org.eclipse.tracecompass.internal.tmf.core.annotations.PeriodicAnnotationProvider) IOutputAnnotationProvider(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider) ArrayList(java.util.ArrayList) List(java.util.List) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) Test(org.junit.Test)

Aggregations

Annotation (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation)22 ArrayList (java.util.ArrayList)17 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)17 Test (org.junit.Test)15 List (java.util.List)10 IOutputAnnotationProvider (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider)10 PeriodicAnnotationProvider (org.eclipse.tracecompass.internal.tmf.core.annotations.PeriodicAnnotationProvider)9 SubMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker)8 RGBAColor (org.eclipse.tracecompass.tmf.core.presentation.RGBAColor)7 AnnotationModel (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationModel)6 Marker (org.eclipse.tracecompass.internal.tmf.core.markers.Marker)5 PeriodicMarker (org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker)5 MarkerSet (org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet)5 SplitMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.SplitMarker)5 WeightedMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker)5 NonNull (org.eclipse.jdt.annotation.NonNull)4 Collection (java.util.Collection)3 OutputElementStyle (org.eclipse.tracecompass.tmf.core.model.OutputElementStyle)3 HashMap (java.util.HashMap)2 Nullable (org.eclipse.jdt.annotation.Nullable)2