1 /*******************************************************************************
2 * Copyright (c) 2013 École Polytechnique de Montréal
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.tests
.project
.model
;
15 import static org
.junit
.Assert
.assertFalse
;
16 import static org
.junit
.Assert
.assertNotNull
;
17 import static org
.junit
.Assert
.assertNull
;
18 import static org
.junit
.Assert
.assertTrue
;
19 import static org
.junit
.Assert
.fail
;
20 import static org
.junit
.Assume
.assumeTrue
;
22 import org
.eclipse
.core
.runtime
.CoreException
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.tests
.shared
.CtfTmfTestTraces
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTraceManager
;
26 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfOpenTraceHelper
;
27 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfProjectElement
;
28 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceElement
;
29 import org
.junit
.After
;
30 import org
.junit
.Before
;
31 import org
.junit
.Test
;
34 * Test suite for the TmfTraceElement class.
36 public class ProjectModelTraceTest
{
38 private TmfProjectElement fixture
;
41 * Perform pre-test initialization.
45 assumeTrue(CtfTmfTestTraces
.tracesExist());
47 fixture
= ProjectModelTestData
.getFilledProject();
48 } catch (CoreException e
) {
54 * Cleans up the project after tests have been executed
57 public void cleanUp() {
59 ProjectModelTestData
.deleteProject(fixture
);
60 } catch (CoreException e
) {
66 * Test the getTrace() and trace opening
69 public void testOpenTrace() {
70 assertNotNull(fixture
);
72 final TmfTraceElement traceElement
= fixture
.getTracesFolder().getTraces().get(0);
75 * Get the trace from the element, it is not opened yet, should be null
77 ITmfTrace trace
= traceElement
.getTrace();
80 TmfOpenTraceHelper
.openTraceFromElement(traceElement
);
82 /* Give the trace a chance to open */
83 ProjectModelTestData
.delayThread(5000);
85 trace
= traceElement
.getTrace();
89 * Open the trace from project, then get from element, both should be
90 * the exact same element as the active trace
92 TmfOpenTraceHelper
.openTraceFromElement(traceElement
);
93 ProjectModelTestData
.delayThread(5000);
95 ITmfTrace trace2
= TmfTraceManager
.getInstance().getActiveTrace();
97 /* The trace was reopened, it is not the same as before */
98 assertFalse(trace2
== trace
);
100 /* Here, the getTrace() should return the same as active trace */
101 trace
= traceElement
.getTrace();
102 assertTrue(trace2
== trace
);