Commit | Line | Data |
---|---|---|
f2a4ccd3 PT |
1 | /******************************************************************************* |
2 | * Copyright (c) 2015 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 | * Patrick Tasse - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests; | |
14 | ||
9cb4e90c | 15 | import static org.junit.Assert.assertEquals; |
f2a4ccd3 PT |
16 | import static org.junit.Assert.assertFalse; |
17 | import static org.junit.Assert.assertTrue; | |
18 | ||
976af99f MK |
19 | import java.util.Arrays; |
20 | import java.util.List; | |
21 | ||
f2a4ccd3 PT |
22 | import org.eclipse.jdt.annotation.NonNull; |
23 | import org.eclipse.jface.bindings.keys.KeyStroke; | |
24 | import org.eclipse.swt.SWT; | |
9cb4e90c PT |
25 | import org.eclipse.swt.graphics.Point; |
26 | import org.eclipse.swt.widgets.Control; | |
f2a4ccd3 PT |
27 | import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; |
28 | import org.eclipse.swtbot.swt.finder.SWTBot; | |
9cb4e90c | 29 | import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; |
f2a4ccd3 PT |
30 | import org.eclipse.swtbot.swt.finder.keyboard.Keyboard; |
31 | import org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory; | |
32 | import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; | |
9cb4e90c PT |
33 | import org.eclipse.swtbot.swt.finder.matchers.WidgetOfType; |
34 | import org.eclipse.swtbot.swt.finder.results.Result; | |
35 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotCanvas; | |
5901a42b | 36 | import org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.resources.ResourcesView; |
f2a4ccd3 PT |
37 | import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; |
38 | import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; | |
39 | import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; | |
40 | import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; | |
f2a4ccd3 | 41 | import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; |
b2c971ec | 42 | import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; |
f2a4ccd3 PT |
43 | import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers; |
44 | import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView; | |
9cb4e90c PT |
45 | import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl; |
46 | import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphMarkerAxis; | |
f2a4ccd3 PT |
47 | import org.eclipse.ui.IWorkbenchPart; |
48 | import org.junit.Before; | |
49 | import org.junit.Ignore; | |
50 | import org.junit.Test; | |
51 | ||
52 | /** | |
53 | * SWTBot tests for Resources view | |
54 | * | |
55 | * @author Patrick Tasse | |
56 | */ | |
976af99f | 57 | public class ResourcesViewTest extends KernelTimeGraphViewTestBase { |
f2a4ccd3 PT |
58 | |
59 | private static final String NEXT_MARKER = "Next Marker"; | |
60 | private static final String PREVIOUS_MARKER = "Previous Marker"; | |
d33eb610 AM |
61 | private static final String SELECT_NEXT_STATE_CHANGE = "Select Next State Change"; |
62 | private static final String SELECT_PREVIOUS_STATE_CHANGE = "Select Previous State Change"; | |
f2a4ccd3 PT |
63 | private static final String ADD_BOOKMARK = "Add Bookmark..."; |
64 | private static final String REMOVE_BOOKMARK = "Remove Bookmark"; | |
65 | private static final String ADD_BOOKMARK_DIALOG = "Add Bookmark"; | |
66 | private static final String LOST_EVENTS = "Lost Events"; | |
67 | private static final String OK = "OK"; | |
68 | private static final Keyboard KEYBOARD = KeyboardFactory.getSWTKeyboard(); | |
b2c971ec MK |
69 | private static final @NonNull ITmfTimestamp START_TIME = TmfTimestamp.fromNanos(1368000272650993664L); |
70 | private static final @NonNull ITmfTimestamp LOST_EVENT_TIME1 = TmfTimestamp.fromNanos(1368000272681793477L); | |
71 | private static final @NonNull ITmfTimestamp LOST_EVENT_END1 = TmfTimestamp.fromNanos(1368000272681793477L + 7425331L); | |
72 | private static final @NonNull ITmfTimestamp LOST_EVENT_TIME2 = TmfTimestamp.fromNanos(1368000272820875850L); | |
73 | private static final @NonNull ITmfTimestamp LOST_EVENT_END2 = TmfTimestamp.fromNanos(1368000272820875850L + 6640670L); | |
74 | private static final @NonNull ITmfTimestamp LOST_EVENT_TIME3 = TmfTimestamp.fromNanos(1368000272882715015L); | |
75 | private static final @NonNull ITmfTimestamp LOST_EVENT_END3 = TmfTimestamp.fromNanos(1368000272882715015L + 11373385L); | |
76 | private static final @NonNull ITmfTimestamp CPU0_TIME1 = TmfTimestamp.fromNanos(1368000272651208412L); | |
77 | private static final @NonNull ITmfTimestamp CPU0_TIME2 = TmfTimestamp.fromNanos(1368000272651852656L); | |
78 | private static final @NonNull ITmfTimestamp CPU0_TIME3 = TmfTimestamp.fromNanos(1368000272652067404L); | |
79 | private static final @NonNull ITmfTimestamp CPU0_TIME4 = TmfTimestamp.fromNanos(1368000272652282152L); | |
80 | private static final @NonNull ITmfTimestamp CPU0_TIME5 = TmfTimestamp.fromNanos(1368000272653141144L); | |
9cb4e90c PT |
81 | private static final int TOP_MARGIN = 1; |
82 | private static final Point TOGGLE_SIZE = new Point(7, 8); | |
83 | private static final Point HIDE_SIZE = new Point(16, 16); | |
f2a4ccd3 | 84 | |
f2a4ccd3 | 85 | |
976af99f MK |
86 | @Override |
87 | protected SWTBotView getViewBot() { | |
5901a42b | 88 | return fBot.viewById(ResourcesView.ID); |
976af99f MK |
89 | } |
90 | ||
91 | @Override | |
92 | protected List<String> getLegendValues() { | |
93 | return Arrays.asList("IDLE", "USERMODE", "SYSCALL", "IRQ", "SOFT_IRQ", "IRQ_ACTIVE", "SOFT_IRQ_RAISED", "SOFT_IRQ_ACTIVE"); | |
94 | } | |
95 | ||
96 | @Override | |
97 | protected List<String> getToolbarTooltips() { | |
98 | return Arrays.asList("Align Views", "Show View Filters", "Show Legend", SEPARATOR, | |
99 | "Reset the Time Scale to Default", "Select Previous State Change", "Select Next State Change", SEPARATOR, | |
100 | "Add Bookmark...", "Previous Marker", "Next Marker", SEPARATOR, | |
101 | "Select Previous Resource", "Select Next Resource", "Zoom In", "Zoom Out" ); | |
102 | } | |
103 | ||
f2a4ccd3 PT |
104 | /** |
105 | * Before Test | |
106 | */ | |
107 | @Override | |
108 | @Before | |
109 | public void before() { | |
5901a42b MK |
110 | SWTBotView viewBot = getViewBot(); |
111 | viewBot.show(); | |
f2a4ccd3 | 112 | super.before(); |
5901a42b | 113 | viewBot.setFocus(); |
f2a4ccd3 PT |
114 | } |
115 | ||
116 | /** | |
117 | * Test keyboard marker navigation using '.' and ',' | |
118 | */ | |
119 | @Test | |
120 | public void testKeyboardSelectNextPreviousMarker() { | |
121 | testNextPreviousMarker( | |
122 | () -> KEYBOARD.pressShortcut(KeyStroke.getInstance('.')), | |
123 | () -> KEYBOARD.pressShortcut(Keystrokes.SHIFT, KeyStroke.getInstance('.')), | |
124 | () -> KEYBOARD.pressShortcut(KeyStroke.getInstance(',')), | |
125 | () -> KEYBOARD.pressShortcut(Keystrokes.SHIFT, KeyStroke.getInstance(','))); | |
126 | } | |
127 | ||
128 | /** | |
129 | * Test tool bar buttons "Next Marker" and "Previous Marker" | |
130 | */ | |
131 | @Test | |
132 | public void testToolBarSelectNextPreviousMarker() { | |
5901a42b | 133 | SWTBotView viewBot = getViewBot(); |
f2a4ccd3 | 134 | testNextPreviousMarker( |
5901a42b MK |
135 | () -> viewBot.toolbarButton(NEXT_MARKER).click(), |
136 | () -> viewBot.toolbarButton(NEXT_MARKER).click(SWT.SHIFT), | |
137 | () -> viewBot.toolbarButton(PREVIOUS_MARKER).click(), | |
138 | () -> viewBot.toolbarButton(PREVIOUS_MARKER).click(SWT.SHIFT)); | |
f2a4ccd3 PT |
139 | } |
140 | ||
141 | private void testNextPreviousMarker(Runnable nextMarker, Runnable shiftNextMarker, Runnable previousMarker, Runnable shiftPreviousMarker) { | |
142 | /* set selection to trace start time */ | |
143 | TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, START_TIME)); | |
144 | timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME), START_TIME); | |
145 | ||
146 | /* select first item */ | |
147 | KEYBOARD.pressShortcut(Keystrokes.HOME); | |
148 | ||
149 | /* click "Next Marker" 3 times */ | |
150 | nextMarker.run(); | |
151 | timeGraphIsReadyCondition(new TmfTimeRange(LOST_EVENT_TIME1, LOST_EVENT_END1), LOST_EVENT_TIME1); | |
152 | nextMarker.run(); | |
153 | timeGraphIsReadyCondition(new TmfTimeRange(LOST_EVENT_TIME2, LOST_EVENT_END2), LOST_EVENT_TIME2); | |
154 | nextMarker.run(); | |
155 | timeGraphIsReadyCondition(new TmfTimeRange(LOST_EVENT_TIME3, LOST_EVENT_END3), LOST_EVENT_TIME3); | |
156 | ||
157 | /* shift-click "Previous Marker" 3 times */ | |
158 | shiftPreviousMarker.run(); | |
159 | timeGraphIsReadyCondition(new TmfTimeRange(LOST_EVENT_TIME3, LOST_EVENT_TIME3), LOST_EVENT_TIME3); | |
160 | shiftPreviousMarker.run(); | |
161 | timeGraphIsReadyCondition(new TmfTimeRange(LOST_EVENT_TIME3, LOST_EVENT_TIME2), LOST_EVENT_TIME2); | |
162 | shiftPreviousMarker.run(); | |
163 | timeGraphIsReadyCondition(new TmfTimeRange(LOST_EVENT_TIME3, LOST_EVENT_TIME1), LOST_EVENT_TIME1); | |
164 | ||
165 | /* shift-click "Next Marker" 3 times */ | |
166 | shiftNextMarker.run(); | |
167 | timeGraphIsReadyCondition(new TmfTimeRange(LOST_EVENT_TIME3, LOST_EVENT_END1), LOST_EVENT_END1); | |
168 | shiftNextMarker.run(); | |
169 | timeGraphIsReadyCondition(new TmfTimeRange(LOST_EVENT_TIME3, LOST_EVENT_END2), LOST_EVENT_END2); | |
170 | shiftNextMarker.run(); | |
171 | timeGraphIsReadyCondition(new TmfTimeRange(LOST_EVENT_TIME3, LOST_EVENT_END3), LOST_EVENT_END3); | |
172 | ||
173 | /* click "Previous Marker" 3 times */ | |
174 | previousMarker.run(); | |
175 | timeGraphIsReadyCondition(new TmfTimeRange(LOST_EVENT_TIME2, LOST_EVENT_END2), LOST_EVENT_TIME2); | |
176 | previousMarker.run(); | |
177 | timeGraphIsReadyCondition(new TmfTimeRange(LOST_EVENT_TIME1, LOST_EVENT_END1), LOST_EVENT_TIME1); | |
178 | previousMarker.run(); | |
179 | timeGraphIsReadyCondition(new TmfTimeRange(LOST_EVENT_TIME1, LOST_EVENT_END1), LOST_EVENT_TIME1); | |
180 | } | |
181 | ||
182 | /** | |
183 | * Test "Show Markers" view menu | |
184 | */ | |
f2a4ccd3 PT |
185 | @Test |
186 | public void testShowMarkers() { | |
5901a42b | 187 | SWTBotView viewBot = getViewBot(); |
f2a4ccd3 PT |
188 | /* set selection to trace start time */ |
189 | TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, START_TIME)); | |
190 | timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME), START_TIME); | |
191 | ||
192 | /* select first item */ | |
193 | KEYBOARD.pressShortcut(Keystrokes.HOME); | |
194 | ||
195 | /* check that "Next Marker" and "Previous Marker" are enabled */ | |
5901a42b MK |
196 | assertTrue(viewBot.toolbarButton(NEXT_MARKER).isEnabled()); |
197 | assertTrue(viewBot.toolbarButton(PREVIOUS_MARKER).isEnabled()); | |
f2a4ccd3 PT |
198 | |
199 | /* disable Lost Events markers */ | |
5901a42b | 200 | viewBot.viewMenu(LOST_EVENTS).click(); |
f2a4ccd3 PT |
201 | |
202 | /* check that "Next Marker" and "Previous Marker" are disabled */ | |
5901a42b MK |
203 | assertFalse(viewBot.toolbarButton(NEXT_MARKER).isEnabled()); |
204 | assertFalse(viewBot.toolbarButton(PREVIOUS_MARKER).isEnabled()); | |
f2a4ccd3 PT |
205 | |
206 | /* enable Lost Events markers */ | |
5901a42b | 207 | viewBot.viewMenu(LOST_EVENTS).click(); |
f2a4ccd3 PT |
208 | |
209 | /* check that "Next Marker" and "Previous Marker" are enabled */ | |
5901a42b MK |
210 | assertTrue(viewBot.toolbarButton(NEXT_MARKER).isEnabled()); |
211 | assertTrue(viewBot.toolbarButton(PREVIOUS_MARKER).isEnabled()); | |
f2a4ccd3 PT |
212 | } |
213 | ||
214 | /** | |
215 | * Test "Next Event" tool bar button sub-menu | |
216 | */ | |
217 | /* SWTBot doesn't support clicking the same tool bar sub-menu twice */ | |
218 | @Ignore | |
219 | @Test | |
220 | public void testMarkerNavigationSubMenu() { | |
5901a42b | 221 | SWTBotView viewBot = getViewBot(); |
f2a4ccd3 PT |
222 | /* set selection to trace start time */ |
223 | TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, START_TIME)); | |
224 | timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME), START_TIME); | |
225 | ||
226 | /* select first item */ | |
227 | KEYBOARD.pressShortcut(Keystrokes.HOME); | |
228 | ||
229 | /* disable Lost Events navigation */ | |
5901a42b | 230 | viewBot.toolbarDropDownButton(NEXT_MARKER).menuItem(LOST_EVENTS).click(); |
f2a4ccd3 PT |
231 | |
232 | /* click "Next Marker" */ | |
5901a42b | 233 | viewBot.toolbarButton(NEXT_MARKER).click(); |
f2a4ccd3 PT |
234 | timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME), START_TIME); |
235 | ||
236 | /* enable Lost Events navigation */ | |
5901a42b | 237 | viewBot.toolbarDropDownButton(NEXT_MARKER).menuItem(LOST_EVENTS).click(); |
f2a4ccd3 PT |
238 | |
239 | /* click "Next Marker" */ | |
5901a42b | 240 | viewBot.toolbarButton(NEXT_MARKER).click(); |
f2a4ccd3 PT |
241 | timeGraphIsReadyCondition(new TmfTimeRange(LOST_EVENT_TIME1, LOST_EVENT_END1), LOST_EVENT_TIME1); |
242 | } | |
243 | ||
244 | /** | |
245 | * Test tool bar button "Add Bookmark..." and "Remove Bookmark" | |
246 | */ | |
247 | @Test | |
248 | public void testAddRemoveBookmark() { | |
5901a42b | 249 | SWTBotView viewBot = getViewBot(); |
f2a4ccd3 PT |
250 | /* change window range to 10 ms */ |
251 | TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(10000000L, ITmfTimestamp.NANOSECOND_SCALE)); | |
252 | TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range)); | |
253 | fBot.waitUntil(ConditionHelpers.windowRange(range)); | |
254 | ||
255 | /* set selection to trace start time */ | |
256 | TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, START_TIME)); | |
257 | timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME), START_TIME); | |
258 | ||
259 | /* select first CPU resource */ | |
260 | KEYBOARD.pressShortcut(Keystrokes.HOME); | |
261 | KEYBOARD.pressShortcut(Keystrokes.DOWN); | |
262 | ||
d33eb610 | 263 | /* click "Select Next State Change" 2 times */ |
5901a42b | 264 | viewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click(); |
f2a4ccd3 | 265 | timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME1, CPU0_TIME1), CPU0_TIME1); |
5901a42b | 266 | viewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click(); |
f2a4ccd3 PT |
267 | timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME2, CPU0_TIME2), CPU0_TIME2); |
268 | ||
269 | /* click "Add Bookmark..." and fill Add Bookmark dialog */ | |
5901a42b | 270 | viewBot.toolbarButton(ADD_BOOKMARK).click(); |
f2a4ccd3 PT |
271 | SWTBot dialogBot = fBot.shell(ADD_BOOKMARK_DIALOG).bot(); |
272 | dialogBot.text().setText("B1"); | |
273 | dialogBot.button(OK).click(); | |
274 | ||
976af99f MK |
275 | /* |
276 | * click "Select Next State Change" 2 times and shift-click "Select Next | |
277 | * State Change | |
278 | */ | |
5901a42b | 279 | viewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click(); |
f2a4ccd3 | 280 | timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME3, CPU0_TIME3), CPU0_TIME3); |
5901a42b | 281 | viewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click(); |
f2a4ccd3 | 282 | timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME4, CPU0_TIME4), CPU0_TIME4); |
5901a42b | 283 | viewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click(SWT.SHIFT); |
f2a4ccd3 PT |
284 | timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME4, CPU0_TIME5), CPU0_TIME5); |
285 | ||
286 | /* click "Add Bookmark..." and fill Add Bookmark dialog */ | |
5901a42b | 287 | viewBot.toolbarButton(ADD_BOOKMARK).click(); |
f2a4ccd3 PT |
288 | dialogBot = fBot.shell(ADD_BOOKMARK_DIALOG).bot(); |
289 | dialogBot.text().setText("B2"); | |
290 | dialogBot.button(OK).click(); | |
291 | ||
292 | /* click "Previous Marker" */ | |
5901a42b | 293 | viewBot.toolbarButton(PREVIOUS_MARKER).click(); |
f2a4ccd3 PT |
294 | timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME2, CPU0_TIME2), CPU0_TIME2); |
295 | ||
296 | /* click "Remove Bookmark" */ | |
5901a42b | 297 | viewBot.toolbarButton(REMOVE_BOOKMARK).click(); |
f2a4ccd3 PT |
298 | |
299 | /* click "Next Marker" */ | |
5901a42b | 300 | viewBot.toolbarButton(NEXT_MARKER).click(); |
f2a4ccd3 PT |
301 | timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME4, CPU0_TIME5), CPU0_TIME5); |
302 | ||
303 | /* click "Remove Bookmark" */ | |
5901a42b | 304 | viewBot.toolbarButton(REMOVE_BOOKMARK).click(); |
f2a4ccd3 PT |
305 | |
306 | /* click "Previous Marker" */ | |
5901a42b | 307 | viewBot.toolbarButton(PREVIOUS_MARKER).click(); |
f2a4ccd3 PT |
308 | timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME4, CPU0_TIME5), CPU0_TIME5); |
309 | ||
d33eb610 | 310 | /* click "Select Previous State Change" */ |
5901a42b | 311 | viewBot.toolbarButton(SELECT_PREVIOUS_STATE_CHANGE).click(); |
f2a4ccd3 PT |
312 | timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME4, CPU0_TIME4), CPU0_TIME4); |
313 | } | |
314 | ||
9cb4e90c PT |
315 | /** |
316 | * Test the marker axis | |
317 | */ | |
318 | @Test | |
319 | public void testMarkerAxis() { | |
5901a42b | 320 | SWTBotView viewBot = getViewBot(); |
9cb4e90c PT |
321 | /* center window range of first lost event range */ |
322 | ITmfTimestamp startTime = LOST_EVENT_TIME1.normalize(-10000000L, ITmfTimestamp.NANOSECOND_SCALE); | |
323 | ITmfTimestamp endTime = LOST_EVENT_END1.normalize(10000000L, ITmfTimestamp.NANOSECOND_SCALE); | |
324 | TmfTimeRange range = new TmfTimeRange(startTime, endTime); | |
325 | TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range)); | |
326 | fBot.waitUntil(ConditionHelpers.windowRange(range)); | |
327 | ||
328 | /* set selection to window start time */ | |
329 | TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, startTime)); | |
330 | timeGraphIsReadyCondition(new TmfTimeRange(startTime, startTime), startTime); | |
331 | ||
332 | /* get marker axis size with one category */ | |
5901a42b | 333 | final TimeGraphMarkerAxis markerAxis = viewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphMarkerAxis.class)); |
9cb4e90c PT |
334 | final Point size1 = getSize(markerAxis); |
335 | ||
336 | /* add bookmark at window start time */ | |
5901a42b | 337 | viewBot.toolbarButton(ADD_BOOKMARK).click(); |
9cb4e90c PT |
338 | SWTBot dialogBot = fBot.shell(ADD_BOOKMARK_DIALOG).bot(); |
339 | dialogBot.text().setText("B"); | |
340 | dialogBot.button(OK).click(); | |
341 | ||
342 | /* get marker axis size with two categories */ | |
343 | final Point size2 = getSize(markerAxis); | |
344 | final int rowHeight = size2.y - size1.y; | |
345 | ||
976af99f MK |
346 | /* |
347 | * get the state area bounds, since we don't know the name space width | |
348 | */ | |
5901a42b | 349 | final TimeGraphControl timeGraph = viewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class)); |
9cb4e90c PT |
350 | int x0 = getXForTime(timeGraph, startTime.toNanos()); |
351 | int x1 = getXForTime(timeGraph, endTime.toNanos()); | |
352 | ||
976af99f MK |
353 | /* |
354 | * click at the center of the marker axis width and first row height, it | |
355 | * should be within the lost event range | |
356 | */ | |
9cb4e90c PT |
357 | final SWTBotCanvas markerAxisCanvas = new SWTBotCanvas(markerAxis); |
358 | markerAxisCanvas.click((x0 + x1) / 2, TOP_MARGIN + rowHeight / 2); | |
359 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(LOST_EVENT_TIME1, LOST_EVENT_END1))); | |
360 | ||
976af99f MK |
361 | /* |
362 | * click near the left of the marker axis width and center of second row | |
363 | * height, it should be on the bookmark label | |
364 | */ | |
9cb4e90c PT |
365 | markerAxisCanvas.click(x0 + 2, TOP_MARGIN + rowHeight + rowHeight / 2); |
366 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(startTime, startTime))); | |
367 | ||
368 | /* click "Remove Bookmark" */ | |
5901a42b | 369 | viewBot.toolbarButton(REMOVE_BOOKMARK).click(); |
9cb4e90c PT |
370 | assertEquals(size1, getSize(markerAxis)); |
371 | ||
372 | /* click the 'expanded' icon to collapse */ | |
373 | markerAxisCanvas.click(TOGGLE_SIZE.x / 2, TOGGLE_SIZE.y / 2); | |
374 | assertEquals(TOGGLE_SIZE.y, getSize(markerAxis).y); | |
375 | ||
376 | /* click the 'collapsed' icon to expand */ | |
377 | markerAxisCanvas.click(TOGGLE_SIZE.x / 2, TOGGLE_SIZE.y / 2); | |
378 | assertEquals(size1, getSize(markerAxis)); | |
379 | ||
380 | /* click on the 'X' icon to hide the 'Lost Events' marker category */ | |
381 | markerAxisCanvas.click(TOGGLE_SIZE.x + HIDE_SIZE.x / 2, TOP_MARGIN + HIDE_SIZE.y / 2); | |
382 | assertEquals(0, getSize(markerAxis).y); | |
383 | ||
384 | /* show Lost Events markers */ | |
5901a42b | 385 | viewBot.viewMenu(LOST_EVENTS).click(); |
9cb4e90c PT |
386 | assertEquals(size1, getSize(markerAxis)); |
387 | } | |
388 | ||
f2a4ccd3 | 389 | private void timeGraphIsReadyCondition(@NonNull TmfTimeRange selectionRange, @NonNull ITmfTimestamp visibleTime) { |
5901a42b | 390 | IWorkbenchPart part = getViewBot().getViewReference().getPart(false); |
f2a4ccd3 PT |
391 | fBot.waitUntil(ConditionHelpers.timeGraphIsReadyCondition((AbstractTimeGraphView) part, selectionRange, visibleTime)); |
392 | } | |
9cb4e90c PT |
393 | |
394 | private static int getXForTime(TimeGraphControl timeGraph, long time) { | |
395 | return UIThreadRunnable.syncExec(new Result<Integer>() { | |
396 | @Override | |
397 | public Integer run() { | |
398 | return timeGraph.getXForTime(time); | |
399 | } | |
400 | }); | |
401 | } | |
402 | ||
403 | private static Point getSize(Control control) { | |
404 | return UIThreadRunnable.syncExec(new Result<Point>() { | |
405 | @Override | |
406 | public Point run() { | |
407 | return control.getSize(); | |
408 | } | |
409 | }); | |
410 | } | |
f2a4ccd3 | 411 | } |