tmf: Add waitUntil / condition to tmf.ui.tests
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests / src / org / eclipse / tracecompass / tmf / analysis / xml / ui / swtbot / tests / latency / PatternLatencyTableViewTest.java
1 /*******************************************************************************
2 * Copyright (c) 2016 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 package org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests.latency;
10
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.fail;
13
14 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
15 import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
16 import org.eclipse.swtbot.swt.finder.results.Result;
17 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
18 import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table.AbstractSegmentStoreTableViewer;
19 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency.PatternLatencyTableView;
20 import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
21 import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils;
22 import org.eclipse.ui.IViewPart;
23 import org.eclipse.ui.IViewReference;
24 import org.junit.Test;
25
26 /**
27 * Test the pattern latency table
28 *
29 * @author Jean-Christian Kouame
30 */
31 public class PatternLatencyTableViewTest extends PatternLatencyViewTestBase {
32
33 private static final String COLUMN_HEADER = "Name";
34 private static final String SYSTEM_CALL_PREFIX = "sys_";
35 private static final String VIEW_ID = PatternLatencyTableView.ID;
36 private static final String VIEW_TITLE = "Latency Table";
37 private PatternLatencyTableView fLatencyView;
38 private AbstractSegmentStoreTableViewer fTable;
39
40 /**
41 * Test the latency view data
42 */
43 @Test
44 public void testData() {
45 getTable();
46 WaitUtils.waitForJobs();
47 assertNotNull(fTable);
48
49 SWTBotTable tableBot = new SWTBotTable(fTable.getTableViewer().getTable());
50 fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, SYSTEM_CALL_PREFIX, 0, 3));
51 tableBot.header(COLUMN_HEADER).click();
52 fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, SYSTEM_CALL_PREFIX, 0, 3));
53 tableBot.header(COLUMN_HEADER).click();
54 fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, SYSTEM_CALL_PREFIX, 0, 3));
55 }
56
57 /**
58 * Get the table associated to the view
59 */
60 private void getTable() {
61 SWTBotView viewBot = fBot.viewById(VIEW_ID);
62 final IViewReference viewReference = viewBot.getViewReference();
63 IViewPart viewPart = UIThreadRunnable.syncExec(new Result<IViewPart>() {
64 @Override
65 public IViewPart run() {
66 return viewReference.getView(true);
67 }
68 });
69 assertNotNull(viewPart);
70 if (!(viewPart instanceof PatternLatencyTableView)) {
71 fail("Could not instanciate view");
72 }
73 fLatencyView = (PatternLatencyTableView) viewPart;
74 fTable = fLatencyView.getSegmentStoreViewer();
75 assertNotNull(fTable);
76 }
77
78 @Override
79 protected String getViewId() {
80 return VIEW_ID;
81 }
82
83 @Override
84 protected String getViewTitle() {
85 return VIEW_TITLE;
86 }
87 }
This page took 0.033513 seconds and 5 git commands to generate.