Commit | Line | Data |
---|---|---|
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 | 15 | package org.eclipse.tracecompass.tmf.ui.tests.views.uml2sd.loader; |
73005152 | 16 | |
90ed5958 AM |
17 | import static org.junit.Assert.assertEquals; |
18 | import static org.junit.Assert.assertNotNull; | |
19 | import static org.junit.Assert.assertTrue; | |
73005152 | 20 | |
90ed5958 | 21 | import java.util.List; |
73005152 | 22 | |
6cfc180e | 23 | import org.eclipse.jdt.annotation.NonNull; |
97c71024 | 24 | import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; |
b2c971ec | 25 | import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; |
2bdf0193 AM |
26 | import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; |
27 | import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; | |
28 | import org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.GraphNode; | |
29 | import org.eclipse.tracecompass.tmf.ui.views.uml2sd.loader.TmfSyncMessage; | |
90ed5958 AM |
30 | import org.junit.AfterClass; |
31 | import org.junit.BeforeClass; | |
32 | import org.junit.Test; | |
73005152 | 33 | |
64636df8 BH |
34 | /** |
35 | * Test cases for time synchronization handling. | |
36 | * | |
37 | * @author Bernd Hufmann | |
64636df8 | 38 | */ |
90ed5958 | 39 | public class TmfUml2SDSyncLoaderTimeTest { |
73005152 BH |
40 | |
41 | // ------------------------------------------------------------------------ | |
42 | // Attributes | |
43 | // ------------------------------------------------------------------------ | |
90ed5958 | 44 | |
73005152 | 45 | // Test case 001 expected values |
6cfc180e | 46 | final static private @NonNull Uml2SDTestTimestamp TC_001_TIME_VALUE = new Uml2SDTestTimestamp(9788642228395L); |
cad06250 | 47 | final static private String TC_001_MESSAGE_NAME = "START_GAME_REPLY"; |
73005152 BH |
48 | final static private int TC_001_PAGE_VALUE = 0; |
49 | final static private int TC_001_START_OCCURRANCE = 6; | |
50 | final static private int TC_001_END_OCCURRANCE = TC_001_START_OCCURRANCE; | |
51 | final static private String TC_001_START_LIFELINE = IUml2SDTestConstants.MASTER_PLAYER_NAME; | |
52 | final static private String TC_001_END_LIFELINE = IUml2SDTestConstants.FIRST_PLAYER_NAME; | |
64636df8 | 53 | |
73005152 | 54 | // Test case 002 expected values |
6cfc180e | 55 | final static private @NonNull Uml2SDTestTimestamp TC_002_TIME_VALUE = new Uml2SDTestTimestamp(9789689830722L); |
cad06250 | 56 | final static private String TC_002_MESSAGE_NAME = "PAUSE_GAME_REQUEST"; |
73005152 BH |
57 | final static private int TC_002_PAGE_VALUE = 2; |
58 | final static private int TC_002_START_OCCURRANCE = 7; | |
59 | final static private int TC_002_END_OCCURRANCE = TC_002_START_OCCURRANCE; | |
60 | final static private String TC_002_START_LIFELINE = IUml2SDTestConstants.FIRST_PLAYER_NAME; | |
61 | final static private String TC_002_END_LIFELINE = IUml2SDTestConstants.MASTER_PLAYER_NAME; | |
64636df8 | 62 | |
73005152 | 63 | // Test case 003 expected values |
6cfc180e | 64 | final static private @NonNull Uml2SDTestTimestamp TC_003_TIME_VALUE = new Uml2SDTestTimestamp(9790750000000L); |
73005152 BH |
65 | final static private int TC_003_PAGE_VALUE = 4; |
66 | ||
67 | // Test case 004 expected values | |
68 | final static private int TC_004_PAGE_VALUE = 0; | |
64636df8 | 69 | |
73005152 BH |
70 | // Test case 005 expected values |
71 | final static private int TC_005_PAGE_VALUE = IUml2SDTestConstants.TOTAL_NUMBER_OF_PAGES - 1; | |
64636df8 | 72 | |
73005152 | 73 | // Test case 006 expected values |
6cfc180e | 74 | final static private @NonNull Uml2SDTestTimestamp TC_006_TIME_VALUE = new Uml2SDTestTimestamp(9792420661655L); |
73005152 BH |
75 | final static private int TC_006_PAGE_VALUE = 4; |
76 | final static private int TC_006_START_OCCURRANCE = IUml2SDTestConstants.MAX_MESSEAGES_PER_PAGE; | |
77 | final static private int TC_006_END_OCCURRANCE = TC_006_START_OCCURRANCE; | |
64636df8 | 78 | |
73005152 | 79 | // Test case 007 expected values |
6cfc180e | 80 | final static private @NonNull Uml2SDTestTimestamp TC_007_TIME_VALUE = new Uml2SDTestTimestamp(9792420756010L); |
73005152 BH |
81 | final static private int TC_007_PAGE_VALUE = 5; |
82 | final static private int TC_007_START_OCCURRANCE = 1; | |
83 | final static private int TC_007_END_OCCURRANCE = TC_007_START_OCCURRANCE; | |
64636df8 | 84 | |
73005152 | 85 | // Test case 008 expected values |
6cfc180e | 86 | final static private @NonNull Uml2SDTestTimestamp TC_008_TIME_VALUE = new Uml2SDTestTimestamp(9788642228395L); |
73005152 | 87 | final static private int TC_008_PAGE_VALUE = 0; |
6cfc180e GB |
88 | final static private @NonNull Uml2SDTestTimestamp TC_008_START_TIME_VALUE = new Uml2SDTestTimestamp(9788642228395L); |
89 | final static private @NonNull Uml2SDTestTimestamp TC_008_END_TIME_VALUE = new Uml2SDTestTimestamp(9789164833324L); | |
73005152 BH |
90 | |
91 | // Test case 009 expected values | |
6cfc180e | 92 | final static private @NonNull Uml2SDTestTimestamp TC_009_TIME_VALUE = new Uml2SDTestTimestamp(9789689220871L); |
7d1ef69c | 93 | final static private int TC_009_PAGE_VALUE = 1; |
6cfc180e GB |
94 | final static private @NonNull Uml2SDTestTimestamp TC_009_START_TIME_VALUE = TC_009_TIME_VALUE; |
95 | final static private @NonNull Uml2SDTestTimestamp TC_009_END_TIME_VALUE = new Uml2SDTestTimestamp(9789773881426L); | |
64636df8 | 96 | |
90ed5958 AM |
97 | // Fields used in tests |
98 | private static Uml2SDTestFacility fFacility; | |
99 | private static List<GraphNode> selection; | |
100 | private static TmfSyncMessage msg; | |
73005152 | 101 | |
4f5d9f9b | 102 | // ------------------------------------------------------------------------ |
90ed5958 | 103 | // Operations |
4f5d9f9b BH |
104 | // ------------------------------------------------------------------------ |
105 | ||
106 | /** | |
90ed5958 | 107 | * Initialization |
64636df8 | 108 | */ |
90ed5958 AM |
109 | @BeforeClass |
110 | public static void setUpClass() { | |
73005152 | 111 | fFacility = Uml2SDTestFacility.getInstance(); |
8e47a700 | 112 | fFacility.init(); |
73005152 BH |
113 | fFacility.selectExperiment(); |
114 | } | |
115 | ||
90ed5958 AM |
116 | /** |
117 | * Cleanup | |
118 | */ | |
119 | @AfterClass | |
120 | public static void tearDownClass() { | |
73005152 | 121 | fFacility.disposeExperiment(); |
8e47a700 | 122 | fFacility.dispose(); |
73005152 | 123 | fFacility = null; |
73005152 | 124 | } |
64636df8 BH |
125 | |
126 | /** | |
90ed5958 AM |
127 | * Test Case: 001 |
128 | * Description: Verify synchToTime (exact time in page), selection of message in page | |
129 | * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToMessageInPage() | |
130 | * Expected result: Correct message is selected. | |
64636df8 | 131 | */ |
90ed5958 AM |
132 | @Test |
133 | public void verifySynchToTimeInPage() { | |
97c71024 | 134 | fFacility.getTrace().broadcast(new TmfSelectionRangeUpdatedSignal(this, TC_001_TIME_VALUE)); |
73005152 BH |
135 | fFacility.getLoader().waitForCompletion(); |
136 | fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY); | |
137 | assertEquals("synchToTime", TC_001_PAGE_VALUE, fFacility.getLoader().currentPage()); | |
90ed5958 | 138 | selection = fFacility.getSdView().getSDWidget().getSelection(); |
73005152 BH |
139 | assertNotNull(selection); |
140 | assertEquals("synchToTime", 1, selection.size()); | |
141 | assertTrue(selection.get(0) instanceof TmfSyncMessage); | |
90ed5958 | 142 | msg = (TmfSyncMessage) selection.get(0); |
73005152 | 143 | assertEquals("synchToTime", TC_001_MESSAGE_NAME, msg.getName()); |
065cc19b | 144 | assertEquals("synchToTime", 0, TC_001_TIME_VALUE.compareTo(msg.getStartTime())); |
73005152 BH |
145 | assertEquals("synchToTime", TC_001_START_OCCURRANCE, msg.getStartOccurrence()); |
146 | assertEquals("synchToTime", TC_001_END_OCCURRANCE, msg.getEndOccurrence()); | |
147 | assertEquals("synchToTime", TC_001_START_LIFELINE, msg.getStartLifeline().getName()); | |
148 | assertEquals("synchToTime", TC_001_END_LIFELINE, msg.getEndLifeline().getName()); | |
90ed5958 | 149 | } |
64636df8 | 150 | |
90ed5958 AM |
151 | /** |
152 | * Test Case: 002 | |
153 | * Description: Verify synchToTime (exact time outside of page), selection of message in page | |
154 | * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage() | |
155 | * Expected result: Correct message is selected. | |
156 | */ | |
157 | @Test | |
158 | public void verifySynchToTimeOutsidePage() { | |
97c71024 | 159 | fFacility.getTrace().broadcast(new TmfSelectionRangeUpdatedSignal(this, TC_002_TIME_VALUE)); |
73005152 BH |
160 | fFacility.getLoader().waitForCompletion(); |
161 | fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY); | |
162 | assertEquals("synchToTime", TC_002_PAGE_VALUE, fFacility.getLoader().currentPage()); | |
163 | selection = fFacility.getSdView().getSDWidget().getSelection(); | |
164 | assertNotNull("synchToTime", selection); | |
165 | assertEquals("synchToTime", 1, selection.size()); | |
166 | assertTrue("synchToTime", selection.get(0) instanceof TmfSyncMessage); | |
167 | msg = (TmfSyncMessage) selection.get(0); | |
168 | assertEquals("synchToTime", TC_002_MESSAGE_NAME, msg.getName()); | |
065cc19b | 169 | assertEquals(0, TC_002_TIME_VALUE.compareTo(msg.getStartTime())); |
73005152 BH |
170 | assertEquals("synchToTime", TC_002_START_OCCURRANCE, msg.getStartOccurrence()); |
171 | assertEquals("synchToTime", TC_002_END_OCCURRANCE, msg.getEndOccurrence()); | |
172 | assertEquals(TC_002_START_LIFELINE, msg.getStartLifeline().getName()); | |
173 | assertEquals(TC_002_END_LIFELINE, msg.getEndLifeline().getName()); | |
90ed5958 | 174 | } |
73005152 | 175 | |
64636df8 | 176 | |
90ed5958 AM |
177 | /** |
178 | * Test Case: 003 | |
179 | * Description: Verify synchToTime (timestamp doesn't exist in trace), no selection of message in page | |
180 | * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage() | |
181 | * Expected result: Move to correct page, currentTime is updated so that focus on the currentTime, but no selection. | |
182 | */ | |
183 | @Test | |
184 | public void verifySynchToTimeNonExisting() { | |
73005152 BH |
185 | fFacility.getLoader().firstPage(); |
186 | ||
97c71024 | 187 | fFacility.getTrace().broadcast(new TmfSelectionRangeUpdatedSignal(this, TC_003_TIME_VALUE)); |
73005152 BH |
188 | fFacility.getLoader().waitForCompletion(); |
189 | fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY); | |
065cc19b | 190 | assertEquals("synchToTime", 0, TC_003_TIME_VALUE.compareTo(fFacility.getLoader().getCurrentTime())); |
73005152 BH |
191 | assertEquals("synchToTime", TC_003_PAGE_VALUE, fFacility.getLoader().currentPage()); |
192 | selection = fFacility.getSdView().getSDWidget().getSelection(); | |
193 | assertNotNull("synchToTime", selection); | |
194 | assertEquals("synchToTime", 0, selection.size()); | |
90ed5958 | 195 | } |
64636df8 | 196 | |
90ed5958 AM |
197 | /** |
198 | * Test Case: 004 | |
199 | * Description: Verify synchToTime (timestamp < experiment time range start) | |
200 | * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage() | |
201 | * Expected result: Move to first page, focus on the beginning of the page, but no selection. | |
202 | */ | |
203 | @Test | |
204 | public void verifySynchToTimeBeforeExpStart() { | |
97c71024 | 205 | fFacility.getTrace().broadcast(new TmfSelectionRangeUpdatedSignal(this, TmfTimestamp.BIG_BANG)); |
73005152 BH |
206 | fFacility.getLoader().waitForCompletion(); |
207 | fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY); | |
208 | assertEquals("synchToTime", TC_004_PAGE_VALUE, fFacility.getLoader().currentPage()); | |
209 | selection = fFacility.getSdView().getSDWidget().getSelection(); | |
210 | assertNotNull("synchToTime", selection); | |
211 | assertEquals("synchToTime", 0, selection.size()); | |
90ed5958 | 212 | } |
64636df8 | 213 | |
90ed5958 AM |
214 | /** |
215 | * Test Case: 005 | |
216 | * Description: Verify synchToTime (timestamp > experiment time range end) | |
217 | * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage() | |
218 | * Expected result: Move to last page, focus on the end of the page, but no selection. | |
219 | */ | |
220 | @Test | |
221 | public void verifySynchToTimeAfterExpEnd() { | |
97c71024 | 222 | fFacility.getTrace().broadcast(new TmfSelectionRangeUpdatedSignal(this, TmfTimestamp.BIG_CRUNCH)); |
73005152 BH |
223 | fFacility.getLoader().waitForCompletion(); |
224 | fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY); | |
225 | assertEquals("synchToTime", TC_005_PAGE_VALUE, fFacility.getLoader().currentPage()); | |
226 | selection = fFacility.getSdView().getSDWidget().getSelection(); | |
227 | assertNotNull(selection); | |
228 | assertEquals("synchToTime", 0, selection.size()); | |
90ed5958 | 229 | } |
73005152 | 230 | |
90ed5958 AM |
231 | /** |
232 | * Test Case: 006 | |
233 | * Description: Verify synchToTime (timestamp of last message in page) | |
234 | * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage(), loader.moveToMessageInPage() | |
235 | * Expected result: Move to correct page, selection of last message in page. | |
236 | */ | |
237 | @Test | |
238 | public void verifySynchToTimeEqualsLast() { | |
97c71024 | 239 | fFacility.getTrace().broadcast(new TmfSelectionRangeUpdatedSignal(this, TC_006_TIME_VALUE)); |
73005152 BH |
240 | fFacility.getLoader().waitForCompletion(); |
241 | fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY); | |
242 | assertEquals("synchToTime", TC_006_PAGE_VALUE, fFacility.getLoader().currentPage()); | |
243 | selection = fFacility.getSdView().getSDWidget().getSelection(); | |
244 | assertNotNull("synchToTime", selection); | |
245 | assertEquals("synchToTime", 1, selection.size()); | |
246 | msg = (TmfSyncMessage) selection.get(0); | |
247 | assertEquals("synchToTime", TC_006_START_OCCURRANCE, msg.getStartOccurrence()); | |
248 | assertEquals("synchToTime", TC_006_END_OCCURRANCE, msg.getEndOccurrence()); | |
90ed5958 | 249 | } |
64636df8 | 250 | |
90ed5958 AM |
251 | /** |
252 | * Test Case: 007 | |
253 | * Description: Verify synchToTime (timestamp of first message in page) | |
254 | * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage() | |
255 | * Expected result: Move to correct page, selection of last message in page. | |
256 | */ | |
257 | @Test | |
258 | public void verifySynchToTimeFirst() { | |
97c71024 | 259 | fFacility.getTrace().broadcast(new TmfSelectionRangeUpdatedSignal(this, TC_007_TIME_VALUE)); |
73005152 BH |
260 | fFacility.getLoader().waitForCompletion(); |
261 | fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY); | |
262 | assertEquals("synchToTime", TC_007_PAGE_VALUE, fFacility.getLoader().currentPage()); | |
263 | selection = fFacility.getSdView().getSDWidget().getSelection(); | |
264 | assertNotNull("synchToTime", selection); | |
265 | msg = (TmfSyncMessage) selection.get(0); | |
266 | assertEquals("synchToTime", 1, selection.size()); | |
267 | assertEquals("synchToTime", TC_007_START_OCCURRANCE, msg.getStartOccurrence()); | |
268 | assertEquals("synchToTime", TC_007_END_OCCURRANCE, msg.getEndOccurrence()); | |
90ed5958 | 269 | } |
73005152 | 270 | |
90ed5958 AM |
271 | /** |
272 | * Test Case: 008 | |
273 | * Description: Verify time range signal (start, end time and current time are in same page) | |
274 | * Verified Methods: loader.synchToTimeRange(), loader.moveToMessage(), loader.moveToMessageInPage() | |
275 | * Expected result: Move to correct page(=page of start time of range), set focus on start time of range, but no selection of message. | |
276 | */ | |
277 | @Test | |
278 | public void verifyTimeRangeSamePage() { | |
73005152 BH |
279 | // 9788.642228395 (page 0) -> 9789.164833324 (page 0) with selected time 9788.642228395 (page 0) |
280 | fFacility.getLoader().firstPage(); | |
281 | TmfTimeRange range = new TmfTimeRange(TC_008_START_TIME_VALUE, TC_008_END_TIME_VALUE); | |
282 | fFacility.getLoader().waitForCompletion(); | |
283 | fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY); | |
97c71024 | 284 | fFacility.getTrace().broadcast(new TmfWindowRangeUpdatedSignal(this, range)); |
73005152 BH |
285 | assertEquals("synchToTimeRange", TC_008_PAGE_VALUE, fFacility.getLoader().currentPage()); |
286 | assertNotNull("synchToTimeRange", fFacility.getLoader().getCurrentTime()); | |
065cc19b | 287 | assertEquals("synchToTimeRange", 0, TC_008_TIME_VALUE.compareTo(fFacility.getLoader().getCurrentTime())); |
73005152 BH |
288 | selection = fFacility.getSdView().getSDWidget().getSelection(); |
289 | // We actually don't want something to be selected!!! | |
290 | assertNotNull("synchToTimeRange", selection); | |
291 | assertEquals("synchToTimeRange", 0, selection.size()); | |
90ed5958 | 292 | } |
64636df8 | 293 | |
90ed5958 AM |
294 | /** |
295 | * Test Case: 009 | |
296 | * Description: Verify time range signal (start and end time are across 2 pages) | |
297 | * Verified Methods: loader.synchToTimeRange(), loader.moveToMessage(), loader.moveToPage() | |
298 | * Expected result: Move to correct page (=page of start time of range), set focus on start time of range, but no selection of message. | |
299 | */ | |
300 | @Test | |
301 | public void verifyTimeRangeDifferentPages() { | |
302 | TmfTimeRange range = new TmfTimeRange(TC_009_START_TIME_VALUE, TC_009_END_TIME_VALUE); | |
97c71024 | 303 | fFacility.getTrace().broadcast(new TmfWindowRangeUpdatedSignal(this, range)); |
73005152 BH |
304 | fFacility.getLoader().waitForCompletion(); |
305 | fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY); | |
306 | assertEquals("synchToTimeRange", TC_009_PAGE_VALUE, fFacility.getLoader().currentPage()); | |
307 | assertNotNull("synchToTimeRange", fFacility.getLoader().getCurrentTime()); | |
065cc19b | 308 | assertEquals("synchToTimeRange", 0, TC_009_TIME_VALUE.compareTo(fFacility.getLoader().getCurrentTime())); |
73005152 BH |
309 | selection = fFacility.getSdView().getSDWidget().getSelection(); |
310 | // We actually don't want something to be selected!!! | |
311 | assertNotNull("synchToTimeRange", selection); | |
312 | assertEquals("synchToTimeRange", 0, selection.size()); | |
73005152 BH |
313 | } |
314 | } |