tmf: Move timestamps to their own package
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui.tests / src / org / eclipse / linuxtools / tmf / ui / tests / views / uml2sd / loader / TmfUml2SDSyncLoaderSignalTest.java
1 /*******************************************************************************
2 * Copyright (c) 2011-2013 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 * Bernd Hufmann - Initial API and implementation
11 * Alexandre Montplaisir - Port to JUnit4
12 *******************************************************************************/
13
14 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader;
15
16 import static org.junit.Assert.assertEquals;
17 import static org.junit.Assert.assertFalse;
18 import static org.junit.Assert.assertTrue;
19
20 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
21 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
22 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
23 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
24 import org.junit.AfterClass;
25 import org.junit.BeforeClass;
26 import org.junit.Test;
27
28 /**
29 * Test cases for signal handling.
30 *
31 * @author Bernd Hufmann
32 */
33 @SuppressWarnings("nls")
34 public class TmfUml2SDSyncLoaderSignalTest {
35
36 private static Uml2SDTestFacility fFacility;
37 private static Uml2SDSignalValidator fTmfComponent;
38
39 private static TmfTimeRange range;
40 private static TmfTimestamp rangeWindow;
41 private static TmfTimestamp currentTime;
42
43 /**
44 * Initialization
45 */
46 @BeforeClass
47 public static void setUpClass() {
48 fFacility = Uml2SDTestFacility.getInstance();
49 fFacility.selectExperiment();
50
51 range = new TmfTimeRange(new Uml2SDTestTimestamp(9789689220871L), new Uml2SDTestTimestamp(9789773881426L));
52 // Get range window for tests below
53 rangeWindow = (TmfTimestamp) range.getEndTime().getDelta(range.getStartTime());
54 currentTime = new Uml2SDTestTimestamp(9789773782043L);
55
56 fFacility.getTrace().broadcast(new TmfRangeSynchSignal(fFacility, range, currentTime));
57 fFacility.delay(IUml2SDTestConstants.BROADCAST_DELAY);
58
59 fTmfComponent = new Uml2SDSignalValidator();
60 }
61
62 /**
63 * Cleanup
64 */
65 @AfterClass
66 public static void tearDownClass() {
67 fFacility.disposeExperiment();
68 fFacility = null;
69 }
70
71 /**
72 * Test Case: 001
73 * Description: Verify that time range signal is send with correct values when going to first page
74 * Verified Methods: broadcast()
75 * Expected result: Time range sync signal is sent with correct range and current time.
76 */
77 @Test
78 public void verifyFirstPageSignal() {
79 currentTime = new Uml2SDTestTimestamp(9788641608418L);
80 range = new TmfTimeRange(currentTime, new Uml2SDTestTimestamp(currentTime.getValue() + rangeWindow.getValue()));
81
82 fTmfComponent.setSignalError(false);
83 fTmfComponent.setSignalReceived(false);
84 fTmfComponent.setCurrentTimeError(false);
85 fTmfComponent.setRangeError(false);
86 fTmfComponent.setSourceError(false);
87
88 // set expected values
89 fTmfComponent.setSource(fFacility.getLoader());
90 fTmfComponent.setCurrentTime(currentTime);
91 fTmfComponent.setCurrentRange(range);
92
93 fFacility.firstPage();
94 assertTrue("TmfRangeSynchSignal", fTmfComponent.isSignalReceived());
95 assertFalse("TmfRangeSynchSignal", fTmfComponent.isSignalError());
96 assertFalse("TmfRangeSynchSignal", fTmfComponent.isCurrentTimeError());
97 assertFalse("TmfRangeSynchSignal", fTmfComponent.isSourceError());
98 assertFalse("TmfRangeSynchSignal", fTmfComponent.isRangeError());
99 }
100
101 /**
102 * Test Case: 002
103 * Description: Verify that time sync signal is sent correctly after selection
104 * Verified Methods: loader.broadcast(), testSelectionChanged
105 * Expected result: Time sync signal is sent with correct current time.
106 */
107 @Test
108 public void verifySelectionSignal() {
109 fTmfComponent.setSignalReceived(false);
110
111 int count = fFacility.getSdView().getFrame().syncMessageCount();
112 assertEquals("Test Preparation", IUml2SDTestConstants.MAX_MESSEAGES_PER_PAGE, count);
113 GraphNode node = fFacility.getSdView().getFrame().getSyncMessage(3);
114
115 // set expected values
116 fTmfComponent.setSource(fFacility.getLoader());
117 fTmfComponent.setCurrentTime(new Uml2SDTestTimestamp(9788642113228L));
118 fTmfComponent.setCurrentRange(null); // not used
119
120 fFacility.getSdView().getSDWidget().moveTo(node); // selects the given node
121 // Wait for the selection to finish - needed due to new platform behavior in Juno
122 fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
123 assertTrue("TmfTimeSynchSignal", fTmfComponent.isSignalReceived());
124 assertFalse("TmfTimeSynchSignal", fTmfComponent.isSignalError());
125 assertFalse("TmfTimeSynchSignal", fTmfComponent.isCurrentTimeError());
126 assertFalse("TmfTimeSynchSignal", fTmfComponent.isSourceError());
127
128 fTmfComponent.setSignalReceived(false);
129
130 fTmfComponent.dispose();
131 }
132 }
This page took 0.032867 seconds and 5 git commands to generate.