tmf ui: Make UML2SD UI tests independent from each other
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui.tests / src / org / eclipse / linuxtools / tmf / ui / tests / views / uml2sd / loader / Uml2SDSignalValidator.java
CommitLineData
73005152 1/*******************************************************************************
c8422608 2 * Copyright (c) 2011, 2013 Ericsson
abbdd66a 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
abbdd66a 8 *
73005152
BH
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 *******************************************************************************/
df0b8ff4 12package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader;
73005152 13
6c13869b 14import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
6c13869b
FC
15import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
16import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
17import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
18import org.eclipse.linuxtools.tmf.core.signal.TmfStartSynchSignal;
19import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
3bd46eef
AM
20import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
21import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
73005152
BH
22
23/**
abbdd66a 24 * Class to implement that certain signals are sent as well as are sent with correct content.
64636df8
BH
25 *
26 * @author Bernd Hufmann
73005152
BH
27 */
28public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignalValidator {
abbdd66a 29
73005152
BH
30 // ------------------------------------------------------------------------
31 // Attributes
32 // ------------------------------------------------------------------------
33 private int fSignalDepth = 0;
34 private boolean fIsSignalReceived = false;
35 private boolean fIsSignalError = false;
36 private boolean fIsSourceError = false;
37 private boolean fIsCurrentTimeError = false;
38 private boolean fIsRangeError = false;
39
40 private Object fSource = null;
41 private TmfTimestamp fCurrentTimestamp = null;
42 private TmfTimeRange fCurrentTimeRange = null;
43
44 // ------------------------------------------------------------------------
45 // Constructor
46 // ------------------------------------------------------------------------
64636df8
BH
47 /**
48 * Constructor
49 */
73005152
BH
50 public Uml2SDSignalValidator() {
51 }
abbdd66a 52
73005152
BH
53 // ------------------------------------------------------------------------
54 // Operations
55 // ------------------------------------------------------------------------
64636df8
BH
56 /**
57 * Signal handler for time synch signal.
58 * @param signal the signal to handle.
59 */
73005152
BH
60 @TmfSignalHandler
61 public void synchToTime(TmfTimeSynchSignal signal) {
abbdd66a 62 // Set results so that it can be validated in the test case
73005152
BH
63 setSignalReceived(true);
64 setSourceError(getSource() != signal.getSource());
65 setCurrentTimeError(!getCurrentTime().equals(signal.getCurrentTime()));
66 }
67
64636df8
BH
68 /**
69 * Signal handler for time range synch signal.
70 * @param signal the signal to handle.
71 */
73005152
BH
72 @TmfSignalHandler
73 public void synchToTimeRange(TmfRangeSynchSignal signal) {
abbdd66a 74 // Set results so that it can be validated in the test case
73005152 75 setSignalReceived(true);
f5944f9f
BH
76 if (getSource() != null) {
77 setSourceError(getSource() != signal.getSource());
78 }
79 if (getCurrentTime() != null) {
80 setCurrentTimeError(!getCurrentTime().equals(signal.getCurrentTime()));
81 }
82 if (getCurrentRange() != null) {
83 setRangeError(!getCurrentRange().equals(signal.getCurrentRange()));
84 }
73005152 85 }
abbdd66a 86
64636df8
BH
87 /**
88 * Signal handler for handling start synch signal.
89 * @param signal the signal to handle.
90 */
73005152
BH
91 @TmfSignalHandler
92 public void startSynch(TmfStartSynchSignal signal) {
93 fSignalDepth++;
abbdd66a 94 // make sure that the signal which is send by the loader class is not handled by the loader class
73005152 95 // after receiving it. i.e. it must not trigger a another signal
abbdd66a 96
73005152
BH
97 // Set results so that it can be validated in the test case
98 setSignalError(fSignalDepth > 1);
99 }
100
64636df8
BH
101 /**
102 * Signal handler for handling end synch signal.
103 * @param signal the signal to handle.
104 */
73005152
BH
105 @TmfSignalHandler
106 public void endSynch(TmfEndSynchSignal signal) {
107 fSignalDepth = fSignalDepth > 0 ? fSignalDepth - 1 : 0;
108 }
abbdd66a 109
73005152
BH
110 @Override
111 public boolean isSignalReceived() {
112 return fIsSignalReceived;
113 }
114
115 @Override
116 public void setSignalReceived(boolean received) {
117 fIsSignalReceived = received;
118 }
119
120 @Override
121 public boolean isSourceError() {
122 return fIsSourceError;
123 }
124
125 @Override
126 public void setSourceError(boolean fIsSourceError) {
127 this.fIsSourceError = fIsSourceError;
128 }
129
130 @Override
131 public boolean isCurrentTimeError() {
132 return fIsCurrentTimeError;
133 }
134
135 @Override
136 public void setCurrentTimeError(boolean fIsCurrentTimeError) {
137 this.fIsCurrentTimeError = fIsCurrentTimeError;
138 }
139
140 @Override
141 public boolean isRangeError() {
142 return fIsRangeError;
143 }
144
145 @Override
146 public void setRangeError(boolean fIsRangeError) {
147 this.fIsRangeError = fIsRangeError;
148 }
149
150 @Override
151 public boolean isSignalError() {
152 return fIsSignalError;
abbdd66a
AM
153 }
154
73005152
BH
155 @Override
156 public void setSignalError(boolean fIsSignalError) {
157 this.fIsSignalError = fIsSignalError;
158 }
159
160 @Override
161 public Object getSource() {
162 return fSource;
163 }
164
165 @Override
166 public void setSource(Object source) {
167 fSource = source;
168 }
abbdd66a 169
73005152
BH
170 @Override
171 public TmfTimestamp getCurrentTime() {
172 return fCurrentTimestamp;
173 }
174
175 @Override
176 public void setCurrentTime(TmfTimestamp currentTime) {
177 fCurrentTimestamp = currentTime == null ? null : new TmfTimestamp(currentTime);
178 }
179
180 @Override
181 public TmfTimeRange getCurrentRange() {
182 return fCurrentTimeRange;
183 }
184
185 @Override
186 public void setCurrentRange(TmfTimeRange currentRange) {
187 fCurrentTimeRange = currentRange == null ? null : new TmfTimeRange(currentRange);
188 }
abbdd66a 189}
73005152 190
This page took 0.042991 seconds and 5 git commands to generate.