Commit | Line | Data |
---|---|---|
73005152 | 1 | /******************************************************************************* |
0fcf3b09 | 2 | * Copyright (c) 2011, 2013 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 | |
df0b8ff4 | 15 | package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader; |
73005152 | 16 | |
90ed5958 AM |
17 | import static org.junit.Assert.assertEquals; |
18 | import static org.junit.Assert.assertFalse; | |
19 | import static org.junit.Assert.assertTrue; | |
73005152 | 20 | |
6c13869b | 21 | import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal; |
0fcf3b09 | 22 | import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal; |
3bd46eef AM |
23 | import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange; |
24 | import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp; | |
73005152 | 25 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode; |
90ed5958 AM |
26 | import org.junit.AfterClass; |
27 | import org.junit.BeforeClass; | |
28 | import org.junit.Test; | |
73005152 | 29 | |
64636df8 BH |
30 | /** |
31 | * Test cases for signal handling. | |
32 | * | |
33 | * @author Bernd Hufmann | |
64636df8 | 34 | */ |
90ed5958 | 35 | public 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; | |
42 | private static TmfTimestamp currentTime; | |
4f5d9f9b BH |
43 | |
44 | /** | |
90ed5958 | 45 | * Initialization |
4f5d9f9b | 46 | */ |
90ed5958 AM |
47 | @BeforeClass |
48 | public static void setUpClass() { | |
73005152 | 49 | fFacility = Uml2SDTestFacility.getInstance(); |
73005152 | 50 | fFacility.selectExperiment(); |
90ed5958 AM |
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 | currentTime = new Uml2SDTestTimestamp(9789773782043L); | |
56 | ||
0fcf3b09 PT |
57 | fFacility.getTrace().broadcast(new TmfRangeSynchSignal(fFacility, range)); |
58 | fFacility.getTrace().broadcast(new TmfTimeSynchSignal(fFacility, currentTime)); | |
90ed5958 AM |
59 | fFacility.delay(IUml2SDTestConstants.BROADCAST_DELAY); |
60 | ||
61 | fTmfComponent = new Uml2SDSignalValidator(); | |
73005152 BH |
62 | } |
63 | ||
90ed5958 AM |
64 | /** |
65 | * Cleanup | |
66 | */ | |
67 | @AfterClass | |
68 | public static void tearDownClass() { | |
73005152 | 69 | fFacility.disposeExperiment(); |
73005152 | 70 | fFacility = null; |
73005152 | 71 | } |
64636df8 BH |
72 | |
73 | /** | |
90ed5958 AM |
74 | * Test Case: 001 |
75 | * Description: Verify that time range signal is send with correct values when going to first page | |
76 | * Verified Methods: broadcast() | |
77 | * Expected result: Time range sync signal is sent with correct range and current time. | |
64636df8 | 78 | */ |
90ed5958 AM |
79 | @Test |
80 | public void verifyFirstPageSignal() { | |
73005152 BH |
81 | currentTime = new Uml2SDTestTimestamp(9788641608418L); |
82 | range = new TmfTimeRange(currentTime, new Uml2SDTestTimestamp(currentTime.getValue() + rangeWindow.getValue())); | |
64636df8 | 83 | |
73005152 BH |
84 | fTmfComponent.setSignalError(false); |
85 | fTmfComponent.setSignalReceived(false); | |
86 | fTmfComponent.setCurrentTimeError(false); | |
87 | fTmfComponent.setRangeError(false); | |
88 | fTmfComponent.setSourceError(false); | |
89 | ||
90 | // set expected values | |
91 | fTmfComponent.setSource(fFacility.getLoader()); | |
92 | fTmfComponent.setCurrentTime(currentTime); | |
93 | fTmfComponent.setCurrentRange(range); | |
94 | ||
95 | fFacility.firstPage(); | |
96 | assertTrue("TmfRangeSynchSignal", fTmfComponent.isSignalReceived()); | |
97 | assertFalse("TmfRangeSynchSignal", fTmfComponent.isSignalError()); | |
98 | assertFalse("TmfRangeSynchSignal", fTmfComponent.isCurrentTimeError()); | |
99 | assertFalse("TmfRangeSynchSignal", fTmfComponent.isSourceError()); | |
100 | assertFalse("TmfRangeSynchSignal", fTmfComponent.isRangeError()); | |
90ed5958 | 101 | } |
64636df8 | 102 | |
90ed5958 AM |
103 | /** |
104 | * Test Case: 002 | |
105 | * Description: Verify that time sync signal is sent correctly after selection | |
106 | * Verified Methods: loader.broadcast(), testSelectionChanged | |
107 | * Expected result: Time sync signal is sent with correct current time. | |
108 | */ | |
109 | @Test | |
110 | public void verifySelectionSignal() { | |
73005152 BH |
111 | fTmfComponent.setSignalReceived(false); |
112 | ||
113 | int count = fFacility.getSdView().getFrame().syncMessageCount(); | |
114 | assertEquals("Test Preparation", IUml2SDTestConstants.MAX_MESSEAGES_PER_PAGE, count); | |
115 | GraphNode node = fFacility.getSdView().getFrame().getSyncMessage(3); | |
116 | ||
117 | // set expected values | |
118 | fTmfComponent.setSource(fFacility.getLoader()); | |
119 | fTmfComponent.setCurrentTime(new Uml2SDTestTimestamp(9788642113228L)); | |
120 | fTmfComponent.setCurrentRange(null); // not used | |
121 | ||
122 | fFacility.getSdView().getSDWidget().moveTo(node); // selects the given node | |
814969ed | 123 | // Wait for the selection to finish - needed due to new platform behavior in Juno |
d5efe032 | 124 | fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY); |
73005152 BH |
125 | assertTrue("TmfTimeSynchSignal", fTmfComponent.isSignalReceived()); |
126 | assertFalse("TmfTimeSynchSignal", fTmfComponent.isSignalError()); | |
127 | assertFalse("TmfTimeSynchSignal", fTmfComponent.isCurrentTimeError()); | |
128 | assertFalse("TmfTimeSynchSignal", fTmfComponent.isSourceError()); | |
129 | ||
130 | fTmfComponent.setSignalReceived(false); | |
64636df8 | 131 | |
73005152 BH |
132 | fTmfComponent.dispose(); |
133 | } | |
134 | } |