Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Khouzam2019-06-05 20:46:01 +0000
committerMatthew Khouzam2019-06-07 13:49:40 +0000
commitdeca0fd2f5d9302600ffc591aa80e836d8332eb4 (patch)
tree26ef019a0636bde37fda16edd906bff13ab0bfc2
parentca3695925ab1355e8a8f87b406fe3c97a8a8a3ed (diff)
downloadorg.eclipse.tracecompass-deca0fd2f5d9302600ffc591aa80e836d8332eb4.tar.gz
org.eclipse.tracecompass-deca0fd2f5d9302600ffc591aa80e836d8332eb4.tar.xz
org.eclipse.tracecompass-deca0fd2f5d9302600ffc591aa80e836d8332eb4.zip
tmf.ui.test: test Time Graph Line
Multiple series test. Change-Id: Iface50d5b54c5d0ef2cd97e5202a9c7590febb85 Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/143412 Tested-by: CI Bot Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com> Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
-rw-r--r--tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotTimeGraphEntry.java30
-rw-r--r--tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/TimeGraphViewStub.java20
-rw-r--r--tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/TimeGraphViewTest.java52
3 files changed, 80 insertions, 22 deletions
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotTimeGraphEntry.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotTimeGraphEntry.java
index f705141a39..f1e61c078e 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotTimeGraphEntry.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotTimeGraphEntry.java
@@ -65,20 +65,19 @@ public class SWTBotTimeGraphEntry extends AbstractSWTBotControl<TimeGraphControl
@Override
protected SWTBotRootMenu contextMenu(final Control control) throws WidgetNotFoundException {
+ Rectangle bounds = absoluteLocation();
+ if (bounds == null) {
+ return null;
+ }
UIThreadRunnable.syncExec(new VoidResult() {
@Override
public void run() {
- Rectangle bounds = widget.getItemBounds(fEntry);
- if (bounds == null) {
- return;
- }
- Point location = widget.toDisplay(bounds.x, bounds.y);
final Event event = new Event();
event.time = (int) System.currentTimeMillis();
event.display = control.getDisplay();
event.widget = control;
- event.x = location.x + widget.getTimeDataProvider().getNameSpace() / 2;
- event.y = location.y + bounds.height / 2;
+ event.x = bounds.x + widget.getTimeDataProvider().getNameSpace() / 2;
+ event.y = bounds.y + bounds.height / 2;
control.notifyListeners(SWT.MenuDetect, event);
}
});
@@ -89,6 +88,23 @@ public class SWTBotTimeGraphEntry extends AbstractSWTBotControl<TimeGraphControl
return new SWTBotRootMenu(waitForMenu.get(0));
}
+ /*
+ * Note this is public
+ */
+ @Override
+ public Rectangle absoluteLocation() {
+ return UIThreadRunnable.syncExec(() -> {
+ Rectangle bounds = widget.getItemBounds(fEntry);
+ if (bounds == null) {
+ return null;
+ }
+ Point location = widget.toDisplay(bounds.x, bounds.y);
+ bounds.x = location.x;
+ bounds.y = location.y;
+ return bounds;
+ });
+ }
+
/**
* Get the child entries of this entry
*
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/TimeGraphViewStub.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/TimeGraphViewStub.java
index 5e59e55aca..912ac23b8f 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/TimeGraphViewStub.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/TimeGraphViewStub.java
@@ -20,7 +20,9 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.swt.graphics.RGBA;
+import org.eclipse.tracecompass.internal.tmf.ui.widgets.timegraph.model.TimeLineEvent;
import org.eclipse.tracecompass.tmf.core.model.timegraph.IFilterProperty;
+import org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
@@ -28,6 +30,7 @@ import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry.DisplayStyle;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.MarkerEvent;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent;
@@ -104,6 +107,7 @@ public class TimeGraphViewStub extends AbstractTimeGraphView {
TimeGraphEntry row5 = new TimeGraphEntry("row5", 80, 160);
TimeGraphEntry row6 = new TimeGraphEntry("row6", 80, 160);
TimeGraphEntry row7 = new TimeGraphEntry("row7", 80, 160);
+ TimeGraphEntry pulse = TimeGraphEntry.create(new TimeGraphEntryModel(444, -1, Collections.singletonList("pulse"), -1, Long.MAX_VALUE), DisplayStyle.LINE);
fEntries.add(hero1);
hero1.addChild(hat1);
@@ -121,6 +125,7 @@ public class TimeGraphViewStub extends AbstractTimeGraphView {
hero2.addChild(row5);
hero2.addChild(row6);
hero2.addChild(row7);
+ fEntries.add(pulse);
fEvents.put(hero1.getName(), Arrays.asList(new NullTimeEvent(hero1, 0, 120)));
// hat
@@ -144,6 +149,16 @@ public class TimeGraphViewStub extends AbstractTimeGraphView {
fEvents.put(row5.getName(), Arrays.asList(new TimeEvent(row5, 80, 50, PIE)));
fEvents.put(row6.getName(), Arrays.asList(new TimeEvent(row6, 90, 60, PIE)));
fEvents.put(row7.getName(), Arrays.asList(new TimeEvent(row7, 110, 30, PIE)));
+ List<ITimeEvent> events = new ArrayList<>();
+ for (long i = -1; i < 160; i++) {
+ double phase = ((double) i) / 16;
+ long value1 = Math.abs((long) (Math.sin(phase) * 1024) + 1024);
+ long value2 = Math.abs((long) (Math.sin(phase + Math.PI * 0.2) * 1024)+1024);
+ long value3 = Math.abs((long) (Math.sin(phase + Math.PI * 0.4) * 1024)+1024);
+ long value4 = Math.abs((long) (Math.sin(phase + Math.PI * 0.6) * 1024)+1024);
+ events.add(new TimeLineEvent(pulse, i, Arrays.asList(value1, value2, value3, value4)));
+ }
+ fEvents.put(pulse.getName(), events);
}
@Override
@@ -195,6 +210,7 @@ public class TimeGraphViewStub extends AbstractTimeGraphView {
refresh();
}
+ @SuppressWarnings("restriction")
@Override
protected @Nullable List<@NonNull ITimeEvent> getEventList(@NonNull TimeGraphEntry entry, long startTime, long endTime, long resolution, @NonNull IProgressMonitor monitor) {
ITmfTrace trace = getTrace();
@@ -207,7 +223,9 @@ public class TimeGraphViewStub extends AbstractTimeGraphView {
for (ITimeEvent ref : references) {
if (ref instanceof NullTimeEvent) {
ret.add(new NullTimeEvent(ref.getEntry(), ref.getTime() + trace.getStartTime().toNanos(), ref.getDuration()));
- } else if (ref instanceof TimeEvent) {
+ } else if (ref instanceof TimeLineEvent) {
+ ret.add(new TimeLineEvent(ref.getEntry(), ref.getTime() + trace.getStartTime().toNanos(), ((TimeLineEvent) ref).getValues()));
+ } if (ref instanceof TimeEvent) {
ret.add(new TimeEvent(ref.getEntry(), ref.getTime() + trace.getStartTime().toNanos(), ref.getDuration(), ((TimeEvent) ref).getValue()));
}
}
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/TimeGraphViewTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/TimeGraphViewTest.java
index ed56e28aba..59a64b5958 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/TimeGraphViewTest.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/TimeGraphViewTest.java
@@ -86,6 +86,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
+import com.google.common.collect.ImmutableMultiset;
import com.google.common.collect.Lists;
import com.google.common.collect.Multiset;
import com.google.common.collect.Multisets;
@@ -556,7 +557,7 @@ public class TimeGraphViewTest {
String pg = "Plumber guy";
String hpc = "Hungry pie chart";
String element = "row2";
- int totalItems = 16;
+ int totalItems = 17;
resetTimeRange();
SWTBotTimeGraph timegraph = fTimeGraph;
@@ -569,19 +570,19 @@ public class TimeGraphViewTest {
timegraph.collapseAll();
entries = timegraph.getEntries();
- assertEquals(2, getVisibleItems(timegraph));
+ assertEquals(3, getVisibleItems(timegraph));
timegraph.getEntry(pg).select();
fireKey(timegraph, true, '+');
- assertEquals(9, getVisibleItems(timegraph));
+ assertEquals(10, getVisibleItems(timegraph));
timegraph.getEntry(pg).select();
fireKey(timegraph, true, '-');
- assertEquals(2, getVisibleItems(timegraph));
+ assertEquals(3, getVisibleItems(timegraph));
timegraph.getEntry(hpc).select();
fireKey(timegraph, true, '+');
- assertEquals(9, getVisibleItems(timegraph));
+ assertEquals(10, getVisibleItems(timegraph));
assertNotNull(timegraph.getEntry(hpc, element));
timegraph.getEntry(pg).select();
@@ -676,9 +677,9 @@ public class TimeGraphViewTest {
fireKeyInGraph(timegraph, '-');
fViewBot.bot().waitUntil(new WindowRangeCondition(view, 77));
/*
- * Note that 'w' and 's' zooming is based on mouse position. Just check if
- * window range was increased or decreased to avoid inaccuracy due to
- * the mouse position in test environment.
+ * Note that 'w' and 's' zooming is based on mouse position. Just check
+ * if window range was increased or decreased to avoid inaccuracy due to
+ * the mouse position in test environment.
*/
long previousRange = getDuration(view.getWindowRange());
fireKeyInGraph(timegraph, 'w');
@@ -714,7 +715,7 @@ public class TimeGraphViewTest {
fireKey(timegraph, true, SWT.PAGE_UP);
assertEquals('[' + pg + ']', timegraph.selection().get(0).toString());
fireKey(timegraph, true, SWT.END);
- assertEquals("[row7]", timegraph.selection().get(0).toString());
+ assertEquals("[pulse]", timegraph.selection().get(0).toString());
fireKey(timegraph, true, SWT.HOME);
assertEquals('[' + pg + ']', timegraph.selection().get(0).toString());
}
@@ -731,23 +732,47 @@ public class TimeGraphViewTest {
timegraph.getEntry(pg).select();
assertEquals(1, timegraph.selection().columnCount());
- assertEquals(16, getVisibleItems(timegraph));
+ assertEquals(17, getVisibleItems(timegraph));
fireKey(timegraph, true, SWT.CR);
assertEquals(1, timegraph.selection().columnCount());
assertEquals('[' + pg + ']', timegraph.selection().get(0).toString());
- assertEquals(9, getVisibleItems(timegraph));
+ assertEquals(10, getVisibleItems(timegraph));
fireKey(timegraph, true, SWT.CR);
assertEquals(1, timegraph.selection().columnCount());
assertEquals('[' + pg + ']', timegraph.selection().get(0).toString());
- assertEquals(16, getVisibleItems(timegraph));
+ assertEquals(17, getVisibleItems(timegraph));
timegraph.getEntry(pg, "Hat1").select();
fireKey(timegraph, true, SWT.CR);
assertEquals(1, timegraph.selection().columnCount());
assertEquals("[Hat1]", timegraph.selection().get(0).toString());
- assertEquals(16, getVisibleItems(timegraph));
+ assertEquals(17, getVisibleItems(timegraph));
+ }
+
+ /**
+ * Test the line entries
+ */
+ @Test
+ public void testTimeLine() {
+ String lines = "pulse";
+ resetTimeRange();
+ SWTBotTimeGraph timegraph = fTimeGraph;
+ assertEquals(0, timegraph.selection().columnCount());
+ ImageHelper currentImage = ImageHelper.waitForNewImage(fBounds, null);
+ SWTBotTimeGraphEntry entry = timegraph.getEntry(lines);
+ // make sure it's visible
+ entry = timegraph.getEntry(lines).select();
+ ImageHelper.waitForNewImage(fBounds, currentImage);
+ Rectangle rect = entry.absoluteLocation();
+ ImageHelper image = ImageHelper.grabImage(rect);
+ ImmutableMultiset<RGB> ms = Multisets.copyHighestCountFirst(image.getHistogram());
+ int black = ms.count(new RGB(0, 0, 0));
+ RGB bgColor = ms.elementSet().iterator().next();
+ int bgCount = ms.count(bgColor);
+ float actual = ((float) black) / (bgCount);
+ assertEquals(0.113f, actual, 0.05f);
}
/**
@@ -1112,5 +1137,4 @@ public class TimeGraphViewTest {
}
}
-
}

Back to the top