tmf: Use tabs in statistics view for each traces
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.core.tests / src / org / eclipse / linuxtools / lttng / core / tests / trace / LTTngExperimentTest.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 Ericsson
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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.lttng.core.tests.trace;
14
15 import java.io.File;
16 import java.io.IOException;
17 import java.net.URISyntaxException;
18 import java.net.URL;
19
20 import junit.framework.TestCase;
21
22 import org.eclipse.core.runtime.FileLocator;
23 import org.eclipse.core.runtime.Path;
24 import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
25 import org.eclipse.linuxtools.internal.lttng.core.event.LttngTimestamp;
26 import org.eclipse.linuxtools.internal.lttng.core.trace.LTTngTrace;
27 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
28 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
29 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
30 import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
31 import org.osgi.framework.FrameworkUtil;
32
33 /**
34 * <b><u>TmfExperimentTest</u></b>
35 * <p>
36 * TODO: Implement me. Please.
37 */
38 @SuppressWarnings("nls")
39 public class LTTngExperimentTest extends TestCase {
40
41 private static final String DIRECTORY = "traceset";
42 private static final String TEST_STREAM = "trace-15316events_nolost_newformat";
43 private static final String EXPERIMENT = "MyExperiment";
44 private static int NB_EVENTS = 15316;
45
46 // Note: Start/end times are for the LTTng *trace*, not the actual events
47 private static final TmfTimestamp fStartTime = new LttngTimestamp(13589759412128L);
48 private static final TmfTimestamp fEndTime = new LttngTimestamp(13589906758692L);
49
50 private static ITmfTrace[] fTestTraces;
51 private static TestExperiment fExperiment;
52
53 // ------------------------------------------------------------------------
54 // Helper class
55 // ------------------------------------------------------------------------
56
57 private static class TestExperiment extends TmfExperiment {
58 public TestExperiment() {
59 super(LttngEvent.class, EXPERIMENT, fTestTraces, 1000);
60 getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
61 }
62 }
63
64 // ------------------------------------------------------------------------
65 // Housekeeping
66 // ------------------------------------------------------------------------
67
68 private synchronized static ITmfTrace[] setupTrace(final String path) {
69 if (fTestTraces == null) {
70 fTestTraces = new ITmfTrace[1];
71 try {
72 final URL location = FileLocator.find(FrameworkUtil.getBundle(LTTngExperimentTest.class), new Path(path), null);
73 final File testfile = new File(FileLocator.toFileURL(location).toURI());
74 final LTTngTrace trace = new LTTngTrace(null, testfile.getPath(), false);
75 fTestTraces[0] = trace;
76 } catch (final URISyntaxException e) {
77 e.printStackTrace();
78 } catch (final IOException e) {
79 e.printStackTrace();
80 } catch (final Exception e) {
81 e.printStackTrace();
82 }
83 }
84 return fTestTraces;
85 }
86
87 private synchronized static void setupExperiment() {
88 if (fExperiment == null) {
89 fExperiment = new TestExperiment();
90 }
91 }
92
93 public LTTngExperimentTest(final String name) throws Exception {
94 super(name);
95 }
96
97 @Override
98 protected void setUp() throws Exception {
99 super.setUp();
100 setupTrace(DIRECTORY + File.separator + TEST_STREAM);
101 setupExperiment();
102 }
103
104 @Override
105 protected void tearDown() throws Exception {
106 super.tearDown();
107 }
108
109 // ------------------------------------------------------------------------
110 // Constructor
111 // ------------------------------------------------------------------------
112
113 public void testBasicTmfExperimentConstructor() {
114
115 assertEquals("GetId", EXPERIMENT, fExperiment.getName());
116 assertEquals("GetNbEvents", NB_EVENTS, fExperiment.getNbEvents());
117
118 final long nbTraceEvents = fExperiment.getTraces()[0].getNbEvents();
119 assertEquals("GetNbEvents", NB_EVENTS, nbTraceEvents);
120
121 final TmfTimeRange timeRange = fExperiment.getTimeRange();
122 assertEquals("getStartTime", fStartTime, timeRange.getStartTime());
123 assertEquals("getEndTime", fEndTime, timeRange.getEndTime());
124 }
125
126 }
This page took 0.033969 seconds and 5 git commands to generate.