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
.assertNotNull
;
16 import static org
.junit
.Assert
.assertNull
;
17 import static org
.junit
.Assert
.assertTrue
;
18 import static org
.junit
.Assert
.fail
;
19 import static org
.junit
.Assume
.assumeTrue
;
21 import org
.eclipse
.core
.runtime
.CoreException
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.tests
.shared
.CtfTmfTestTrace
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTraceManager
;
25 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfOpenTraceHelper
;
26 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfProjectElement
;
27 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceElement
;
28 import org
.junit
.After
;
29 import org
.junit
.Before
;
30 import org
.junit
.Test
;
33 * Test suite for the TmfTraceElement class.
35 * @author Geneviève Bastien
37 public class ProjectModelTraceTest
{
39 private TmfProjectElement fixture
;
42 * Perform pre-test initialization.
46 assumeTrue(CtfTmfTestTrace
.KERNEL
.exists());
48 fixture
= ProjectModelTestData
.getFilledProject();
49 } catch (CoreException e
) {
55 * Cleans up the project after tests have been executed
58 public void cleanUp() {
59 ProjectModelTestData
.deleteProject(fixture
);
63 * Test the getTrace() and trace opening
66 public void testOpenTrace() {
67 assertNotNull(fixture
);
69 final TmfTraceElement traceElement
= fixture
.getTracesFolder().getTraces().get(0);
72 * Get the trace from the element, it is not opened yet, should be null
74 ITmfTrace trace
= traceElement
.getTrace();
77 TmfOpenTraceHelper
.openTraceFromElement(traceElement
);
79 /* Give the trace a chance to open */
80 ProjectModelTestData
.delayThread(500);
82 trace
= traceElement
.getTrace();
86 * Open the trace from project, then get from element, both should be
87 * the exact same element as the active trace
89 TmfOpenTraceHelper
.openTraceFromElement(traceElement
);
90 ProjectModelTestData
.delayThread(500);
92 ITmfTrace trace2
= TmfTraceManager
.getInstance().getActiveTrace();
94 /* The trace was reopened, it should be the same as before */
95 assertTrue(trace2
== trace
);
97 /* Here, the getTrace() should return the same as active trace */
98 trace
= traceElement
.getTrace();
99 assertTrue(trace2
== trace
);