1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 É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
.tracecompass
.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
;
20 import org
.eclipse
.core
.runtime
.CoreException
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
23 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfOpenTraceHelper
;
24 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfProjectElement
;
25 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfTraceElement
;
26 import org
.eclipse
.tracecompass
.tmf
.ui
.tests
.shared
.ProjectModelTestData
;
27 import org
.eclipse
.tracecompass
.tmf
.ui
.tests
.shared
.WaitTimeoutException
;
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.
47 fixture
= ProjectModelTestData
.getFilledProject();
48 } catch (CoreException e
) {
54 * Cleans up the project after tests have been executed
57 public void cleanUp() {
58 ProjectModelTestData
.deleteProject(fixture
);
62 * Test the getTrace() and trace opening
65 public void testOpenTrace() {
66 assertNotNull(fixture
);
68 final TmfTraceElement traceElement
= fixture
.getTracesFolder().getTraces().get(0);
71 * Get the trace from the element, it is not opened yet, should be null
73 ITmfTrace trace
= traceElement
.getTrace();
76 TmfOpenTraceHelper
.openTraceFromElement(traceElement
);
78 /* Give the trace a chance to open */
80 ProjectModelTestData
.delayUntilTraceOpened(traceElement
);
81 } catch (WaitTimeoutException e
) {
82 fail("The trace did not open in a reasonable delay");
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
);
94 ProjectModelTestData
.delayUntilTraceOpened(traceElement
);
95 } catch (WaitTimeoutException e
) {
96 fail("The trace did not open in a reasonable delay");
99 ITmfTrace trace2
= TmfTraceManager
.getInstance().getActiveTrace();
101 /* The trace was reopened, it should be the same as before */
102 assertTrue(trace2
== trace
);
104 /* Here, the getTrace() should return the same as active trace */
105 trace
= traceElement
.getTrace();
106 assertTrue(trace2
== trace
);