lttng control: Fix number of connection nodes not zero after deletion.
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui.tests / src / org / eclipse / tracecompass / tmf / ui / tests / views / uml2sd / loader / TmfUml2SDSyncLoaderSignalTest.java
CommitLineData
73005152 1/*******************************************************************************
ed902a2b 2 * Copyright (c) 2011, 2014 Ericsson
64636df8 3 *
73005152
BH
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
64636df8 8 *
73005152
BH
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
90ed5958 11 * Alexandre Montplaisir - Port to JUnit4
0fcf3b09 12 * Patrick Tasse - Support selection range
73005152 13 *******************************************************************************/
90ed5958 14
2bdf0193 15package org.eclipse.tracecompass.tmf.ui.tests.views.uml2sd.loader;
73005152 16
90ed5958
AM
17import static org.junit.Assert.assertEquals;
18import static org.junit.Assert.assertFalse;
19import static org.junit.Assert.assertTrue;
73005152 20
97c71024
AM
21import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
22import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
2bdf0193
AM
23import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
24import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
25import org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.GraphNode;
90ed5958
AM
26import org.junit.AfterClass;
27import org.junit.BeforeClass;
28import org.junit.Test;
73005152 29
64636df8
BH
30/**
31 * Test cases for signal handling.
32 *
33 * @author Bernd Hufmann
64636df8 34 */
90ed5958 35public class TmfUml2SDSyncLoaderSignalTest {
73005152 36
90ed5958
AM
37 private static Uml2SDTestFacility fFacility;
38 private static Uml2SDSignalValidator fTmfComponent;
4f5d9f9b 39
90ed5958
AM
40 private static TmfTimeRange range;
41 private static TmfTimestamp rangeWindow;
4f5d9f9b
BH
42
43 /**
90ed5958 44 * Initialization
4f5d9f9b 45 */
90ed5958
AM
46 @BeforeClass
47 public static void setUpClass() {
73005152 48 fFacility = Uml2SDTestFacility.getInstance();
73005152 49 fFacility.selectExperiment();
90ed5958
AM
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());
6cfc180e 54 TmfTimestamp currentTime = new Uml2SDTestTimestamp(9789773782043L);
90ed5958 55
97c71024
AM
56 fFacility.getTrace().broadcast(new TmfWindowRangeUpdatedSignal(fFacility, range));
57 fFacility.getTrace().broadcast(new TmfSelectionRangeUpdatedSignal(fFacility, currentTime));
90ed5958
AM
58 fFacility.delay(IUml2SDTestConstants.BROADCAST_DELAY);
59
60 fTmfComponent = new Uml2SDSignalValidator();
73005152
BH
61 }
62
90ed5958
AM
63 /**
64 * Cleanup
65 */
66 @AfterClass
67 public static void tearDownClass() {
73005152 68 fFacility.disposeExperiment();
73005152 69 fFacility = null;
73005152 70 }
64636df8
BH
71
72 /**
90ed5958
AM
73 * Test Case: 001
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.
64636df8 77 */
90ed5958
AM
78 @Test
79 public void verifyFirstPageSignal() {
6cfc180e 80 TmfTimestamp currentTime = new Uml2SDTestTimestamp(9788641608418L);
73005152 81 range = new TmfTimeRange(currentTime, new Uml2SDTestTimestamp(currentTime.getValue() + rangeWindow.getValue()));
64636df8 82
73005152
BH
83 fTmfComponent.setSignalError(false);
84 fTmfComponent.setSignalReceived(false);
85 fTmfComponent.setCurrentTimeError(false);
86 fTmfComponent.setRangeError(false);
87 fTmfComponent.setSourceError(false);
88
89 // set expected values
90 fTmfComponent.setSource(fFacility.getLoader());
91 fTmfComponent.setCurrentTime(currentTime);
92 fTmfComponent.setCurrentRange(range);
93
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());
90ed5958 100 }
64636df8 101
90ed5958
AM
102 /**
103 * Test Case: 002
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.
107 */
108 @Test
109 public void verifySelectionSignal() {
73005152
BH
110 fTmfComponent.setSignalReceived(false);
111
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);
115
116 // set expected values
117 fTmfComponent.setSource(fFacility.getLoader());
118 fTmfComponent.setCurrentTime(new Uml2SDTestTimestamp(9788642113228L));
119 fTmfComponent.setCurrentRange(null); // not used
120
121 fFacility.getSdView().getSDWidget().moveTo(node); // selects the given node
814969ed 122 // Wait for the selection to finish - needed due to new platform behavior in Juno
d5efe032 123 fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
73005152
BH
124 assertTrue("TmfTimeSynchSignal", fTmfComponent.isSignalReceived());
125 assertFalse("TmfTimeSynchSignal", fTmfComponent.isSignalError());
126 assertFalse("TmfTimeSynchSignal", fTmfComponent.isCurrentTimeError());
127 assertFalse("TmfTimeSynchSignal", fTmfComponent.isSourceError());
128
129 fTmfComponent.setSignalReceived(false);
64636df8 130
73005152
BH
131 fTmfComponent.dispose();
132 }
133}
This page took 0.077775 seconds and 5 git commands to generate.