use of org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker in project tracecompass by tracecompass.
the class MarkerConfigXmlParserTest method testParse.
/**
* Test the parse method
*
* @throws IOException if an exception occurs
*/
@Test
public void testParse() throws IOException {
File file = File.createTempFile("markers", "xml");
try (FileWriter fw = new FileWriter(file)) {
fw.write(XML_CONTENT);
fw.flush();
List<MarkerSet> markerSets = MarkerConfigXmlParser.parse(file.getAbsolutePath());
assertEquals(2, markerSets.size());
MarkerSet setA = markerSets.get(0);
assertEquals("Set A", setA.getName());
assertEquals("set.a", setA.getId());
assertEquals(3, setA.getMarkers().size());
PeriodicMarker markerA1 = (PeriodicMarker) setA.getMarkers().get(0);
assertEquals("Marker A-1", markerA1.getName());
assertEquals("A-1 %d", markerA1.getLabel());
assertEquals("marker.a.1", markerA1.getId());
assertEquals("ref.a.1", markerA1.getReferenceId());
assertEquals("#0000ff", markerA1.getColor());
assertEquals(10.0, markerA1.getPeriod(), 0);
assertEquals("ms", markerA1.getUnit());
assertEquals(Range.closed(0L, 4095L), markerA1.getRange());
assertEquals(0, markerA1.getOffset());
assertEquals(1, markerA1.getSubMarkers().size());
SplitMarker submarkerA11 = (SplitMarker) markerA1.getSubMarkers().get(0);
assertEquals("Submarker A-1-1", submarkerA11.getName());
assertEquals("A-1-1 %d", submarkerA11.getLabel());
assertEquals("submarker.a.1.1", submarkerA11.getId());
assertEquals("#000000", submarkerA11.getColor());
assertEquals(Range.closed(0L, 99L), submarkerA11.getRange());
assertEquals(1, submarkerA11.getSubMarkers().size());
SplitMarker submarkerA111 = (SplitMarker) submarkerA11.getSubMarkers().get(0);
assertEquals("Submarker A-1-1-1", submarkerA111.getName());
assertEquals("A-1-1-1 %d", submarkerA111.getLabel());
assertEquals("submarker.a.1.1.1", submarkerA111.getId());
assertEquals("#000000", submarkerA111.getColor());
assertEquals(Range.closed(0L, 9L), submarkerA111.getRange());
assertEquals(0, submarkerA111.getSubMarkers().size());
PeriodicMarker markerA2 = (PeriodicMarker) setA.getMarkers().get(1);
assertEquals("Marker A-2", markerA2.getName());
assertEquals("A-2 %d", markerA2.getLabel());
assertEquals("marker.a.2", markerA2.getId());
assertEquals("ref.a.2", markerA2.getReferenceId());
assertEquals("#ff0000", markerA2.getColor());
assertEquals(20.0, markerA2.getPeriod(), 0);
assertEquals("us", markerA2.getUnit());
assertEquals(Range.atLeast(0L), markerA2.getRange());
assertEquals(0, markerA2.getOffset());
assertEquals(0, markerA2.getSubMarkers().size());
PeriodicMarker markerA3 = (PeriodicMarker) setA.getMarkers().get(2);
assertEquals("Marker A-3", markerA3.getName());
assertEquals("A-3 %d", markerA3.getLabel());
assertEquals("marker.a.3", markerA3.getId());
assertEquals("ref.a.3", markerA3.getReferenceId());
assertEquals("#00ff00", markerA3.getColor());
assertEquals(2.5, markerA3.getPeriod(), 0);
assertEquals("ns", markerA3.getUnit());
assertEquals(Range.atLeast(0L), markerA3.getRange());
assertEquals(0, markerA3.getOffset());
assertEquals(1, markerA3.getSubMarkers().size());
WeightedMarker submarkerA31 = (WeightedMarker) markerA3.getSubMarkers().get(0);
assertEquals("Submarker A-3-1", submarkerA31.getName());
assertEquals(0, submarkerA31.getSubMarkers().size());
assertEquals(2, submarkerA31.getSegments().size());
MarkerSegment submarkerA31a = submarkerA31.getSegments().get(0);
assertEquals(null, submarkerA31a.getName());
assertEquals("A-3-1-a %d", submarkerA31a.getLabel());
assertEquals("marker.a.3.1.a", submarkerA31a.getId());
assertEquals("#aaaaaa", submarkerA31a.getColor());
assertEquals(1, submarkerA31a.getLength());
assertEquals(0, submarkerA31a.getSubMarkers().size());
MarkerSegment submarkerA31b = submarkerA31.getSegments().get(1);
assertEquals(null, submarkerA31b.getName());
assertEquals("A-3-1-b %d", submarkerA31b.getLabel());
assertEquals("marker.a.3.1.b", submarkerA31b.getId());
assertEquals("#bbbbbb", submarkerA31b.getColor());
assertEquals(2, submarkerA31b.getLength());
assertEquals(0, submarkerA31b.getSubMarkers().size());
MarkerSet setB = markerSets.get(1);
assertEquals("Set B", setB.getName());
assertEquals("set.b", setB.getId());
assertEquals(1, setB.getMarkers().size());
PeriodicMarker markerB1 = (PeriodicMarker) setB.getMarkers().get(0);
assertEquals("Marker B-1", markerB1.getName());
assertEquals("B-1 %d", markerB1.getLabel());
assertEquals("marker.b.1", markerB1.getId());
assertEquals("ref.b.1", markerB1.getReferenceId());
assertEquals("#010203", markerB1.getColor());
assertEquals(1000.0, markerB1.getPeriod(), 0);
assertEquals("cycles", markerB1.getUnit());
assertEquals(Range.atLeast(1L), markerB1.getRange());
assertEquals(5, markerB1.getOffset());
assertEquals(2, markerB1.getSubMarkers().size());
SplitMarker submarkerB11 = (SplitMarker) markerB1.getSubMarkers().get(0);
assertEquals("Submarker B-1-1", submarkerB11.getName());
assertEquals("submarker.b.1.1", submarkerB11.getId());
assertEquals("#010203", submarkerB11.getColor());
assertEquals(Range.closed(1L, 10L), submarkerB11.getRange());
assertEquals(0, submarkerB11.getSubMarkers().size());
SplitMarker submarkerB12 = (SplitMarker) markerB1.getSubMarkers().get(1);
assertEquals("Submarker B-1-2", submarkerB12.getName());
assertEquals("submarker.b.1.2", submarkerB12.getId());
assertEquals("#010203", submarkerB12.getColor());
assertEquals(Range.closed(1L, 100L), submarkerB12.getRange());
assertEquals(0, submarkerB12.getSubMarkers().size());
} finally {
file.delete();
}
}
use of org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker in project tracecompass by tracecompass.
the class MarkerTest method testConstructor.
/**
* Test the PeriodicMarker constructor
*/
@Test
public void testConstructor() {
PeriodicMarker marker = new PeriodicMarker("name", "label", "id", "referenceid", "color", 1.0, "ms", Range.atLeast(0L), 0L, ImmutableRangeSet.of(Range.all()));
assertEquals("name", marker.getName());
assertEquals("label", marker.getLabel());
assertEquals("id", marker.getId());
assertEquals("referenceid", marker.getReferenceId());
assertEquals("color", marker.getColor());
assertEquals(1.0, marker.getPeriod(), 0);
assertEquals("ms", marker.getUnit());
assertEquals(Range.atLeast(0L), marker.getRange());
assertEquals(0L, marker.getOffset());
assertEquals(ImmutableRangeSet.of(Range.all()), marker.getIndexRange());
assertEquals(0, marker.getSubMarkers().size());
}
use of org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker in project tracecompass by tracecompass.
the class CustomAnnotationProvider method getLabel.
/**
* Get the label of the marker, may be a format string
*
* @return the label of the marker
*/
public Map<String, String> getLabel() {
Map<String, String> labels = new HashMap<>();
if (fMarkerSet != null) {
for (Marker marker : fMarkerSet.getMarkers()) {
if (marker instanceof PeriodicMarker) {
PeriodicMarker periodicMarker = (PeriodicMarker) marker;
labels.put(Objects.requireNonNull(periodicMarker.getName()), Objects.requireNonNull(periodicMarker.getLabel()));
}
}
}
return labels;
}
use of org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker in project tracecompass by tracecompass.
the class CustomAnnotationProviderTest method testWeightedWithSubmarkers.
/**
* Test weighted with submarkers
*/
@Test
public void testWeightedWithSubmarkers() {
List<Annotation> annotationList;
MarkerSet set = new MarkerSet("name", "id");
fProvider.configure(set);
assertAnnotationCategoriesModelResponse(Collections.emptyList(), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
/*
* period: 40 ns, offset: 0 ns, range: 0..49, indexRange: 30..31,40
*
* requested range: 0 ns-4000 ns
*
* expected annotations: 1200 ns[30] 1240 ns[31] 1600 ns[40] 3200 ns[30]
* 3240 ns[31] 3600 ns[40]
*/
Marker markerD = new PeriodicMarker("D", "D %d", "d", "ref.d", COLOR_STR, 40.0, "ns", Range.closed(0L, 49L), 0L, ImmutableRangeSet.<Long>builder().add(Range.closed(30L, 31L)).add(Range.singleton(40L)).build());
set.addMarker(markerD);
/*
* period: 40 ns with segment weights {2,1,3}, offset: 0 ns,
* range:0..49, indexRange:30..31,40
*
* requested range: 0 ns-2000 ns
*
* expected annotations: 1200 ns[0] 1220[2] 1240 ns[0] 1260[2] 1600 ns[0]
* 1620 ns[2]
*/
WeightedMarker markerE = new WeightedMarker("E");
markerD.addSubMarker(markerE);
MarkerSegment segmentE1 = new MarkerSegment("E1 %d", "e1", RED_STR, 2);
markerE.addSegment(segmentE1);
MarkerSegment segmentE2 = new MarkerSegment("E2 %d", "e2", "", 1);
markerE.addSegment(segmentE2);
MarkerSegment segmentE3 = new MarkerSegment("E3 %d", "e3", INVALID_STR, 3);
markerE.addSegment(segmentE3);
fProvider.configure(set);
assertAnnotationCategoriesModelResponse(Arrays.asList("D", "E"), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
annotationList = getAnnotationList("E", 0L, 2000L, 1L, new NullProgressMonitor());
assertEquals(6, annotationList.size());
int i = 0;
for (long t = 0L; t < 2000L; t += 40L) {
int index = (int) (t / 40L) % 50;
if (index == 30L || index == 31L || index == 40L) {
validateAnnotation(annotationList.get(i), t, 13L, "E", String.format("E1 %d", 0), RED);
i++;
/*
* segment 2 does not have visible annotation due to empty color
* name
*/
validateAnnotation(annotationList.get(i), t + 20L, 20L, "E", String.format("E3 %d", 2), DEFAULT);
i++;
}
}
}
use of org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker in project tracecompass by tracecompass.
the class MarkerSetTest method testAddMarker.
/**
* Test the method addMarker
*/
@Test
public void testAddMarker() {
MarkerSet markerSet = new MarkerSet("name", "id");
Marker markerA = new PeriodicMarker("A", "A %d", "a", "ref.a", "color1", 1.0, "ms", Range.atLeast(1L), 1L, ImmutableRangeSet.of(Range.atLeast(1L)));
markerSet.addMarker(markerA);
Marker markerB = new PeriodicMarker("B", "B %d", "b", "ref.b", "color2", 2.0, "ns", Range.atLeast(2L), 2L, ImmutableRangeSet.of(Range.atLeast(2L)));
markerSet.addMarker(markerB);
assertEquals(Arrays.asList(markerA, markerB), markerSet.getMarkers());
}
Aggregations