1 /*******************************************************************************
2 * Copyright (c) 2011-2013 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 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.tests
.views
.uml2sd
.loader
;
16 import static org
.junit
.Assert
.assertEquals
;
17 import static org
.junit
.Assert
.assertFalse
;
18 import static org
.junit
.Assert
.assertTrue
;
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
;
29 * Test cases for signal handling.
31 * @author Bernd Hufmann
33 public class TmfUml2SDSyncLoaderSignalTest
{
35 private static Uml2SDTestFacility fFacility
;
36 private static Uml2SDSignalValidator fTmfComponent
;
38 private static TmfTimeRange range
;
39 private static TmfTimestamp rangeWindow
;
40 private static TmfTimestamp currentTime
;
46 public static void setUpClass() {
47 fFacility
= Uml2SDTestFacility
.getInstance();
48 fFacility
.selectExperiment();
50 range
= new TmfTimeRange(new Uml2SDTestTimestamp(9789689220871L), new Uml2SDTestTimestamp(9789773881426L));
51 // Get range window for tests below
52 rangeWindow
= (TmfTimestamp
) range
.getEndTime().getDelta(range
.getStartTime());
53 currentTime
= new Uml2SDTestTimestamp(9789773782043L);
55 fFacility
.getTrace().broadcast(new TmfRangeSynchSignal(fFacility
, range
, currentTime
));
56 fFacility
.delay(IUml2SDTestConstants
.BROADCAST_DELAY
);
58 fTmfComponent
= new Uml2SDSignalValidator();
65 public static void tearDownClass() {
66 fFacility
.disposeExperiment();
72 * Description: Verify that time range signal is send with correct values when going to first page
73 * Verified Methods: broadcast()
74 * Expected result: Time range sync signal is sent with correct range and current time.
77 public void verifyFirstPageSignal() {
78 currentTime
= new Uml2SDTestTimestamp(9788641608418L);
79 range
= new TmfTimeRange(currentTime
, new Uml2SDTestTimestamp(currentTime
.getValue() + rangeWindow
.getValue()));
81 fTmfComponent
.setSignalError(false);
82 fTmfComponent
.setSignalReceived(false);
83 fTmfComponent
.setCurrentTimeError(false);
84 fTmfComponent
.setRangeError(false);
85 fTmfComponent
.setSourceError(false);
87 // set expected values
88 fTmfComponent
.setSource(fFacility
.getLoader());
89 fTmfComponent
.setCurrentTime(currentTime
);
90 fTmfComponent
.setCurrentRange(range
);
92 fFacility
.firstPage();
93 assertTrue("TmfRangeSynchSignal", fTmfComponent
.isSignalReceived());
94 assertFalse("TmfRangeSynchSignal", fTmfComponent
.isSignalError());
95 assertFalse("TmfRangeSynchSignal", fTmfComponent
.isCurrentTimeError());
96 assertFalse("TmfRangeSynchSignal", fTmfComponent
.isSourceError());
97 assertFalse("TmfRangeSynchSignal", fTmfComponent
.isRangeError());
102 * Description: Verify that time sync signal is sent correctly after selection
103 * Verified Methods: loader.broadcast(), testSelectionChanged
104 * Expected result: Time sync signal is sent with correct current time.
107 public void verifySelectionSignal() {
108 fTmfComponent
.setSignalReceived(false);
110 int count
= fFacility
.getSdView().getFrame().syncMessageCount();
111 assertEquals("Test Preparation", IUml2SDTestConstants
.MAX_MESSEAGES_PER_PAGE
, count
);
112 GraphNode node
= fFacility
.getSdView().getFrame().getSyncMessage(3);
114 // set expected values
115 fTmfComponent
.setSource(fFacility
.getLoader());
116 fTmfComponent
.setCurrentTime(new Uml2SDTestTimestamp(9788642113228L));
117 fTmfComponent
.setCurrentRange(null); // not used
119 fFacility
.getSdView().getSDWidget().moveTo(node
); // selects the given node
120 // Wait for the selection to finish - needed due to new platform behavior in Juno
121 fFacility
.delay(IUml2SDTestConstants
.GUI_REFESH_DELAY
);
122 assertTrue("TmfTimeSynchSignal", fTmfComponent
.isSignalReceived());
123 assertFalse("TmfTimeSynchSignal", fTmfComponent
.isSignalError());
124 assertFalse("TmfTimeSynchSignal", fTmfComponent
.isCurrentTimeError());
125 assertFalse("TmfTimeSynchSignal", fTmfComponent
.isSourceError());
127 fTmfComponent
.setSignalReceived(false);
129 fTmfComponent
.dispose();