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