1 /*******************************************************************************
2 * Copyright (c) 2011, 2014 Ericsson
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 * Bernd Hufmann - Initial API and implementation
11 * Alexandre Montplaisir - Port to JUnit4
12 * Patrick Tasse - Support selection range
13 *******************************************************************************/
15 package org
.eclipse
.tracecompass
.tmf
.ui
.tests
.views
.uml2sd
.loader
;
17 import static org
.junit
.Assert
.assertEquals
;
18 import static org
.junit
.Assert
.assertFalse
;
19 import static org
.junit
.Assert
.assertTrue
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfRangeSynchSignal
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTimeSynchSignal
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimeRange
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimestamp
;
25 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.core
.GraphNode
;
26 import org
.junit
.AfterClass
;
27 import org
.junit
.BeforeClass
;
28 import org
.junit
.Test
;
31 * Test cases for signal handling.
33 * @author Bernd Hufmann
35 public class TmfUml2SDSyncLoaderSignalTest
{
37 private static Uml2SDTestFacility fFacility
;
38 private static Uml2SDSignalValidator fTmfComponent
;
40 private static TmfTimeRange range
;
41 private static TmfTimestamp rangeWindow
;
47 public static void setUpClass() {
48 fFacility
= Uml2SDTestFacility
.getInstance();
49 fFacility
.selectExperiment();
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 TmfTimestamp currentTime
= new Uml2SDTestTimestamp(9789773782043L);
56 fFacility
.getTrace().broadcast(new TmfRangeSynchSignal(fFacility
, range
));
57 fFacility
.getTrace().broadcast(new TmfTimeSynchSignal(fFacility
, currentTime
));
58 fFacility
.delay(IUml2SDTestConstants
.BROADCAST_DELAY
);
60 fTmfComponent
= new Uml2SDSignalValidator();
67 public static void tearDownClass() {
68 fFacility
.disposeExperiment();
74 * Description: Verify that time range signal is send with correct values when going to first page
75 * Verified Methods: broadcast()
76 * Expected result: Time range sync signal is sent with correct range and current time.
79 public void verifyFirstPageSignal() {
80 TmfTimestamp currentTime
= new Uml2SDTestTimestamp(9788641608418L);
81 range
= new TmfTimeRange(currentTime
, new Uml2SDTestTimestamp(currentTime
.getValue() + rangeWindow
.getValue()));
83 fTmfComponent
.setSignalError(false);
84 fTmfComponent
.setSignalReceived(false);
85 fTmfComponent
.setCurrentTimeError(false);
86 fTmfComponent
.setRangeError(false);
87 fTmfComponent
.setSourceError(false);
89 // set expected values
90 fTmfComponent
.setSource(fFacility
.getLoader());
91 fTmfComponent
.setCurrentTime(currentTime
);
92 fTmfComponent
.setCurrentRange(range
);
94 fFacility
.firstPage();
95 assertTrue("TmfRangeSynchSignal", fTmfComponent
.isSignalReceived());
96 assertFalse("TmfRangeSynchSignal", fTmfComponent
.isSignalError());
97 assertFalse("TmfRangeSynchSignal", fTmfComponent
.isCurrentTimeError());
98 assertFalse("TmfRangeSynchSignal", fTmfComponent
.isSourceError());
99 assertFalse("TmfRangeSynchSignal", fTmfComponent
.isRangeError());
104 * Description: Verify that time sync signal is sent correctly after selection
105 * Verified Methods: loader.broadcast(), testSelectionChanged
106 * Expected result: Time sync signal is sent with correct current time.
109 public void verifySelectionSignal() {
110 fTmfComponent
.setSignalReceived(false);
112 int count
= fFacility
.getSdView().getFrame().syncMessageCount();
113 assertEquals("Test Preparation", IUml2SDTestConstants
.MAX_MESSEAGES_PER_PAGE
, count
);
114 GraphNode node
= fFacility
.getSdView().getFrame().getSyncMessage(3);
116 // set expected values
117 fTmfComponent
.setSource(fFacility
.getLoader());
118 fTmfComponent
.setCurrentTime(new Uml2SDTestTimestamp(9788642113228L));
119 fTmfComponent
.setCurrentRange(null); // not used
121 fFacility
.getSdView().getSDWidget().moveTo(node
); // selects the given node
122 // Wait for the selection to finish - needed due to new platform behavior in Juno
123 fFacility
.delay(IUml2SDTestConstants
.GUI_REFESH_DELAY
);
124 assertTrue("TmfTimeSynchSignal", fTmfComponent
.isSignalReceived());
125 assertFalse("TmfTimeSynchSignal", fTmfComponent
.isSignalError());
126 assertFalse("TmfTimeSynchSignal", fTmfComponent
.isCurrentTimeError());
127 assertFalse("TmfTimeSynchSignal", fTmfComponent
.isSourceError());
129 fTmfComponent
.setSignalReceived(false);
131 fTmfComponent
.dispose();