lttng.kernel: remove getX86IrqVectorsEntry/Exit
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests / src / org / eclipse / tracecompass / tmf / analysis / xml / ui / swtbot / tests / latency / PatternLatencyViewTestBase.java
CommitLineData
4d760144
JCK
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
10package org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests.latency;
11
12import static org.junit.Assert.fail;
13
14import java.io.IOException;
15
16import org.apache.log4j.ConsoleAppender;
17import org.apache.log4j.Logger;
18import org.apache.log4j.SimpleLayout;
19import org.eclipse.core.runtime.FileLocator;
20import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
21import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
22import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
23import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
24import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
25import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlAnalysisModuleSource;
26import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlUtils;
27import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
28import org.eclipse.tracecompass.tmf.analysis.xml.core.tests.common.TmfXmlTestFiles;
29import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
30import org.junit.After;
31import org.junit.Before;
32import org.junit.BeforeClass;
33import org.junit.runner.RunWith;
34
35/**
36 * Base class for pattern latency view test
37 *
38 * @author Jean-Christian Kouame
39 */
40@RunWith(SWTBotJunit4ClassRunner.class)
41public abstract class PatternLatencyViewTestBase {
42
43 private static final String PROJECT_NAME = "test";
44 private static final String TRACE_TYPE = "org.eclipse.linuxtools.lttng2.kernel.tracetype";
45
46 /** The Log4j logger instance. */
47 private static final Logger fLogger = Logger.getRootLogger();
48 /**
49 * The workbench bot
50 */
51 protected static SWTWorkbenchBot fBot;
52
53 /**
54 * Things to setup
55 */
56 @BeforeClass
57 public static void beforeClass() {
58
59 SWTBotUtils.initialize();
60 Thread.currentThread().setName("SWTBotTest");
61 /* set up for swtbot */
62 SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
63 SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
64 fLogger.removeAllAppenders();
65 fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT));
66 SWTWorkbenchBot bot = new SWTWorkbenchBot();
67 SWTBotUtils.closeView("welcome", bot);
68 /* Switch perspectives */
69 SWTBotUtils.switchToTracingPerspective();
70 /* Finish waiting for eclipse to load */
71 SWTBotUtils.waitForJobs();
72
73 fBot = new SWTWorkbenchBot();
74
75 loadXmlFile();
76 openTrace();
77 }
78
79 /**
80 * Create a tracing project and open the test trace
81 */
82 private static void openTrace() {
83 try {
84 String tracePath = FileLocator.toFileURL(CtfTestTrace.ARM_64_BIT_HEADER.getTraceURL()).getPath();
85 SWTBotUtils.createProject(PROJECT_NAME);
86 SWTBotUtils.openTrace(PROJECT_NAME, tracePath, TRACE_TYPE);
87 SWTBotUtils.waitForJobs();
88 } catch (IOException e) {
89 fail("Failed to get the trace.");
90 }
91 }
92
93 /**
94 * Bypassing the native import wizard and programmatically load the XML
95 * analysis
96 */
97 private static void loadXmlFile() {
98 XmlUtils.addXmlFile(TmfXmlTestFiles.VALID_PATTERN_FILE.getFile());
99 XmlAnalysisModuleSource.notifyModuleChange();
100 }
101
102 /**
103 * set up before the test and open the latency view
104 */
105 @Before
106 public void before() {
107 openView(getViewTitle());
108 }
109
110 /**
111 * Closes the view
112 */
113 @After
114 public void closeView() {
115 fBot.closeAllEditors();
116 SWTBotUtils.deleteProject(PROJECT_NAME, fBot);
117
118 final SWTWorkbenchBot swtWorkbenchBot = new SWTWorkbenchBot();
119 SWTBotView viewBot = swtWorkbenchBot.viewById(getViewId());
120 viewBot.close();
121 }
122
123 /**
124 * Open a pattern latency view
125 *
126 * @param viewTitle
127 * The view title
128 */
129 private static void openView(final String viewTitle) {
130 SWTBotTreeItem treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);
131 treeItem = treeItem.expand();
132 treeItem = treeItem.getNode(0).expand();
133 treeItem = treeItem.expandNode("Views", "XML system call analysis");
134 treeItem = treeItem.getNode(viewTitle);
135 treeItem.doubleClick();
136 SWTBotUtils.waitForJobs();
137 }
138
139 /**
140 * Get the id of the latency view tested
141 *
142 * @return The view id
143 */
144 protected abstract String getViewId();
145
146 /**
147 * Get the the latency view title
148 *
149 * @return The view title
150 */
151 protected abstract String getViewTitle();
152}
This page took 0.031547 seconds and 5 git commands to generate.