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 java
.util
.concurrent
.TimeoutException
;
22 import org
.eclipse
.core
.runtime
.CoreException
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
25 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfOpenTraceHelper
;
26 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfProjectElement
;
27 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfTraceElement
;
28 import org
.eclipse
.tracecompass
.tmf
.ui
.tests
.shared
.ProjectModelTestData
;
29 import org
.junit
.After
;
30 import org
.junit
.Before
;
31 import org
.junit
.Test
;
34 * Test suite for the TmfTraceElement class.
36 * @author Geneviève Bastien
38 public class ProjectModelTraceTest
{
40 private TmfProjectElement fixture
;
43 * Perform pre-test initialization.
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 */
81 ProjectModelTestData
.delayUntilTraceOpened(traceElement
);
82 } catch (TimeoutException e
) {
83 fail("The trace did not open in a reasonable delay");
86 trace
= traceElement
.getTrace();
90 * Open the trace from project, then get from element, both should be
91 * the exact same element as the active trace
93 TmfOpenTraceHelper
.openTraceFromElement(traceElement
);
95 ProjectModelTestData
.delayUntilTraceOpened(traceElement
);
96 } catch (TimeoutException e
) {
97 fail("The trace did not open in a reasonable delay");
100 ITmfTrace trace2
= TmfTraceManager
.getInstance().getActiveTrace();
102 /* The trace was reopened, it should be the same as before */
103 assertTrue(trace2
== trace
);
105 /* Here, the getTrace() should return the same as active trace */
106 trace
= traceElement
.getTrace();
107 assertTrue(trace2
== trace
);