Merge branch 'master' into lttng-luna
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui.tests / src / org / eclipse / linuxtools / tmf / ui / tests / project / model / ProjectModelTraceTest.java
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
13 package org.eclipse.linuxtools.tmf.ui.tests.project.model;
14
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;
20
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;
31
32 /**
33 * Test suite for the TmfTraceElement class.
34 *
35 * @author Geneviève Bastien
36 */
37 public class ProjectModelTraceTest {
38
39 private TmfProjectElement fixture;
40
41 /**
42 * Perform pre-test initialization.
43 */
44 @Before
45 public void setUp() {
46 assumeTrue(CtfTmfTestTrace.KERNEL.exists());
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() {
59 ProjectModelTestData.deleteProject(fixture);
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 */
80 ProjectModelTestData.delayThread(500);
81
82 trace = traceElement.getTrace();
83 assertNotNull(trace);
84
85 /*
86 * Open the trace from project, then get from element, both should be
87 * the exact same element as the active trace
88 */
89 TmfOpenTraceHelper.openTraceFromElement(traceElement);
90 ProjectModelTestData.delayThread(500);
91
92 ITmfTrace trace2 = TmfTraceManager.getInstance().getActiveTrace();
93
94 /* The trace was reopened, it should be the same as before */
95 assertTrue(trace2 == trace);
96
97 /* Here, the getTrace() should return the same as active trace */
98 trace = traceElement.getTrace();
99 assertTrue(trace2 == trace);
100 }
101
102 }
This page took 0.0351 seconds and 6 git commands to generate.