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