X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tmf%2Forg.eclipse.tracecompass.tmf.core.tests%2Fsrc%2Forg%2Feclipse%2Ftracecompass%2Ftmf%2Fcore%2Ftests%2Ftrace%2FTmfTraceUtilsTest.java;h=cf89ffd4e43960d8ae07ecc1fb980afb756262de;hb=cf392b7362cabd3c0bbcf23436afcb799d5b0471;hp=69ee1098eb63a59fc80e49b5852081662380ea97;hpb=4f3ea7da0235b04ffb1164987cb360993828d230;p=deliverable%2Ftracecompass.git diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfTraceUtilsTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfTraceUtilsTest.java index 69ee1098eb..cf89ffd4e4 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfTraceUtilsTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfTraceUtilsTest.java @@ -14,12 +14,14 @@ package org.eclipse.tracecompass.tmf.core.tests.trace; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.util.Collection; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect; @@ -80,6 +82,27 @@ public class TmfTraceUtilsTest { } + private static class TestEventAspect implements ITmfEventAspect { + + public static final Integer RESOLVED_VALUE = 2; + + @Override + public @NonNull String getName() { + return "test"; + } + + @Override + public @NonNull String getHelpText() { + return "test"; + } + + @Override + public @Nullable Integer resolve(@NonNull ITmfEvent event) { + return RESOLVED_VALUE; + } + + } + // ------------------------------------------------------------------------ // Housekeeping // ------------------------------------------------------------------------ @@ -157,9 +180,33 @@ public class TmfTraceUtilsTest { assertNotNull(event); /* Make sure the CPU aspect returns the expected value */ - Object cpuObj = TmfTraceUtils.resolveEventAspectOfClassForEvent(trace, TmfCpuAspect.class, event); + Object cpuObj = TmfTraceUtils.resolveEventAspectOfClassForEvent(trace, TmfCpuAspect.class, event); assertNotNull(cpuObj); assertEquals(1, cpuObj); } + + /** + * Test the {@link TmfTraceUtils#registerEventAspect(ITmfEventAspect)} method + */ + @Test + public void testAdditionalAspects() { + TmfTrace trace = fTrace; + + assertNotNull(trace); + + ITmfContext context = trace.seekEvent(0L); + ITmfEvent event = trace.getNext(context); + assertNotNull(event); + + Object obj = TmfTraceUtils.resolveEventAspectOfClassForEvent(trace, TestEventAspect.class, event); + assertNull(obj); + + // Register the aspect + TmfTraceUtils.registerEventAspect(new TestEventAspect()); + // See that the aspect is resolved now + obj = TmfTraceUtils.resolveEventAspectOfClassForEvent(trace, TestEventAspect.class, event); + assertNotNull(obj); + assertEquals(TestEventAspect.RESOLVED_VALUE, obj); + } }