tmf: Fix NullPointerException TmfTraceElement
authorBernd Hufmann <Bernd.Hufmann@ericsson.com>
Fri, 22 Nov 2013 17:45:17 +0000 (12:45 -0500)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Fri, 22 Nov 2013 19:11:27 +0000 (14:11 -0500)
and fix timing issues in TMF UI tests. The NPE and timing issues
causes problems in the TMF UI tests. That's way they are committed in
one patch.

Change-Id: If80562c11f9daab5756adf982b35a9e6b308e03b
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/18748
Tested-by: Hudson CI
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/project/model/ProjectModelAnalysisTest.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java

index b999f8817b0c82eba86b3f72ba457d4f310f43c5..d0dd7c4ed9d92869a4cec44765f6deb94766250a 100644 (file)
@@ -152,11 +152,18 @@ public class ProjectModelAnalysisTest {
         traceElement.closeEditors();
         analysis.activateParent();
 
+        ITmfTrace trace = null;
+        int cnt = 0;
+
         /* Give some time to the trace to open */
-        ProjectModelTestData.delayThread(1000);
+        while ((trace == null) && (cnt++ < 10)) {
+
+            ProjectModelTestData.delayThread(500);
+
+            /* Get the analysis module associated with the element */
+            trace = traceElement.getTrace();
+        }
 
-        /* Get the analysis module associated with the element */
-        ITmfTrace trace = traceElement.getTrace();
         assertNotNull(trace);
         TestAnalysisUi module = (TestAnalysisUi) trace.getAnalysisModule(analysis.getAnalysisId());
         assertNotNull(module);
index 398291c3e56ca441b1a753cc92b7cc4466b57aa8..5041aefb300f89705712ad7f4cfc7dfc96926a07 100644 (file)
@@ -717,7 +717,8 @@ public class TmfTraceElement extends TmfWithFolderElement implements IActionFilt
      */
     @TmfSignalHandler
     public void traceOpened(TmfTraceOpenedSignal signal) {
-        if (!signal.getTrace().getResource().equals(getResource())) {
+        IResource resource = signal.getTrace().getResource();
+        if ((resource == null) || !resource.equals(getResource())) {
             return;
         }
 
This page took 0.026878 seconds and 5 git commands to generate.