1 /*******************************************************************************
2 * Copyright (c) 2016 Ericsson
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 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.lttng2
.kernel
.ui
.swtbot
.tests
;
12 import static org
.junit
.Assert
.assertEquals
;
13 import static org
.junit
.Assert
.assertNotNull
;
14 import static org
.junit
.Assert
.assertTrue
;
16 import java
.util
.ArrayList
;
17 import java
.util
.List
;
19 import org
.eclipse
.swtbot
.eclipse
.finder
.widgets
.SWTBotView
;
20 import org
.eclipse
.swtbot
.swt
.finder
.SWTBot
;
21 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotLabel
;
22 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotToolbarButton
;
23 import org
.junit
.Test
;
26 * Kernel based time graph view test base. Used to test time graph views using
29 * @author Matthew Khouzam
32 public abstract class KernelTimeGraphViewTestBase
extends KernelTestBase
{
35 * Tooltip used for separator toolbar items
37 protected static final String SEPARATOR
= "";
40 * Get an SWTBotView of the view being tested
42 * @return a bot of the view being tested
44 protected abstract SWTBotView
getViewBot();
47 * Get the tool bar tool tip text values in order
49 * @return the tool bar tool tip text values in order
51 protected abstract List
<String
> getToolbarTooltips();
54 * Get the legend text values in order
56 * @return the legend text values in order
58 protected abstract List
<String
> getLegendValues();
61 * Test toolbar button order and that all buttons are enabled and visible
64 public void testToolbar() {
65 List
<SWTBotToolbarButton
> buttons
= getViewBot().getToolbarButtons();
66 List
<String
> tooltipsExpected
= getToolbarTooltips();
67 List
<String
> tooltips
= new ArrayList
<>();
68 for (SWTBotToolbarButton button
: buttons
) {
69 tooltips
.add(button
.getToolTipText());
70 assertTrue(button
.getText() + " enabled", button
.isEnabled());
71 assertTrue(button
.getText() + " visible", button
.isVisible());
73 assertEquals(tooltipsExpected
, tooltips
);
77 * Test the legend content
80 public void testLegend() {
81 List
<String
> labelValues
= getLegendValues();
82 SWTBotToolbarButton legendButton
= getViewBot().toolbarButton("Show Legend");
84 fBot
.waitUntil(org
.eclipse
.swtbot
.swt
.finder
.waits
.Conditions
.shellIsActive("States Transition Visualizer"));
85 SWTBot bot
= fBot
.activeShell().bot();
86 for (int i
= 1; i
<= labelValues
.size(); i
++) {
87 SWTBotLabel label
= bot
.label(i
);
89 assertEquals(labelValues
.get(i
- 1), label
.getText());
91 bot
.button("OK").click();