ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui.tests / src / org / eclipse / linuxtools / tmf / ui / tests / project / model / ProjectModelTraceTest.java
CommitLineData
87644443
GB
1/*******************************************************************************
2 * Copyright (c) 2013 École Polytechnique de Montréal
3 *
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
8 *
9 * Contributors:
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.tmf.ui.tests.project.model;
14
87644443
GB
15import static org.junit.Assert.assertNotNull;
16import static org.junit.Assert.assertNull;
17import static org.junit.Assert.assertTrue;
18import static org.junit.Assert.fail;
87644443 19
bc5f2035
GB
20import java.util.concurrent.TimeoutException;
21
87644443 22import org.eclipse.core.runtime.CoreException;
87644443
GB
23import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
24import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
25import org.eclipse.linuxtools.tmf.ui.project.model.TmfOpenTraceHelper;
26import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement;
27import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
3d2e4ad3 28import org.eclipse.linuxtools.tmf.ui.tests.shared.ProjectModelTestData;
87644443
GB
29import org.junit.After;
30import org.junit.Before;
31import org.junit.Test;
32
33/**
34 * Test suite for the TmfTraceElement class.
c068a752
GB
35 *
36 * @author Geneviève Bastien
87644443
GB
37 */
38public class ProjectModelTraceTest {
39
40 private TmfProjectElement fixture;
41
42 /**
43 * Perform pre-test initialization.
44 */
45 @Before
46 public void setUp() {
87644443
GB
47 try {
48 fixture = ProjectModelTestData.getFilledProject();
49 } catch (CoreException e) {
50 fail(e.getMessage());
51 }
52 }
53
54 /**
55 * Cleans up the project after tests have been executed
56 */
57 @After
58 public void cleanUp() {
c068a752 59 ProjectModelTestData.deleteProject(fixture);
87644443
GB
60 }
61
62 /**
63 * Test the getTrace() and trace opening
64 */
65 @Test
66 public void testOpenTrace() {
67 assertNotNull(fixture);
68
69 final TmfTraceElement traceElement = fixture.getTracesFolder().getTraces().get(0);
70
71 /*
72 * Get the trace from the element, it is not opened yet, should be null
73 */
74 ITmfTrace trace = traceElement.getTrace();
75 assertNull(trace);
76
77 TmfOpenTraceHelper.openTraceFromElement(traceElement);
78
79 /* Give the trace a chance to open */
bc5f2035
GB
80 try {
81 ProjectModelTestData.delayUntilTraceOpened(traceElement);
82 } catch (TimeoutException e) {
83 fail("The trace did not open in a reasonable delay");
84 }
87644443
GB
85
86 trace = traceElement.getTrace();
87 assertNotNull(trace);
88
89 /*
90 * Open the trace from project, then get from element, both should be
91 * the exact same element as the active trace
92 */
93 TmfOpenTraceHelper.openTraceFromElement(traceElement);
bc5f2035
GB
94 try {
95 ProjectModelTestData.delayUntilTraceOpened(traceElement);
96 } catch (TimeoutException e) {
97 fail("The trace did not open in a reasonable delay");
98 }
87644443
GB
99
100 ITmfTrace trace2 = TmfTraceManager.getInstance().getActiveTrace();
101
67c53011
PT
102 /* The trace was reopened, it should be the same as before */
103 assertTrue(trace2 == trace);
87644443
GB
104
105 /* Here, the getTrace() should return the same as active trace */
106 trace = traceElement.getTrace();
107 assertTrue(trace2 == trace);
108 }
109
110}
This page took 0.040874 seconds and 5 git commands to generate.