package org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.Assert.assertTrue;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.log4j.varia.NullAppender;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportConfirmation;
import org.eclipse.tracecompass.internal.tmf.ui.views.statistics.TmfStatisticsViewImpl;
+import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
-import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
+import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
import org.eclipse.tracecompass.tmf.ui.editors.TmfEventsEditor;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
protected static final String TRACE_FOLDER = "synctraces";
/** Trace type name for generic CTF traces */
protected static final String TRACE_TYPE_NAME = "Generic CTF Trace";
- /** A Generic CTF Trace*/
- protected static final CtfTmfTestTrace fTrace = CtfTmfTestTrace.SYNC_DEST;
+ /** A Generic CTF Trace */
+ protected static final @NonNull CtfTestTrace fTrace = CtfTestTrace.SYNC_DEST;
/** SWT BOT workbench reference */
protected static SWTWorkbenchBot fBot;
/** Wizard to use */
/** Test Class setup */
@BeforeClass
public static void init() {
- assumeTrue(fTrace.exists());
- SWTBotUtils.failIfUIThread();
+ SWTBotUtils.initialize();
/* set up for swtbot */
SWTBotPreferences.TIMEOUT = 50000; /* 50 second timeout */
/**
* Creates a tracing projects
+ *
+ * @param traceProjectName
+ * the name of the test project
*/
- protected void createProject() {
+ protected static void createProject(String traceProjectName) {
SWTBotUtils.focusMainWindow(fBot.shells());
fBot.menu("File").menu("New").menu("Project...").click();
fBot.shell("Tracing Project").setFocus();
final SWTBotText text = fBot.text();
- text.setText(getProjectName());
+ text.setText(traceProjectName);
fBot.button("Finish").click();
SWTBotUtils.waitForJobs();
* Finishes the wizard
*/
protected void importFinish() {
+ importFinish(ImportConfirmation.CONTINUE);
+ }
+
+ /**
+ * Finishes the wizard
+ *
+ * @param confirmationMode
+ * a confirmation value
+ * Note: Only {@link ImportConfirmation#RENAME_ALL},
+ * {@link ImportConfirmation#OVERWRITE_ALL},
+ * {@link ImportConfirmation#CONTINUE} are supported
+ */
+ protected void importFinish(ImportConfirmation confirmationMode) {
SWTBotShell shell = fBot.activeShell();
final SWTBotButton finishButton = fBot.button("Finish");
finishButton.click();
+ if (confirmationMode == ImportConfirmation.RENAME_ALL) {
+ fBot.waitUntil(Conditions.shellIsActive("Confirmation"));
+ SWTBotShell shell2 = fBot.activeShell();
+ SWTBotButton button = shell2.bot().button("Rename All");
+ button.click();
+ } else if (confirmationMode == ImportConfirmation.OVERWRITE_ALL) {
+ fBot.waitUntil(Conditions.shellIsActive("Confirmation"));
+ SWTBotShell shell2 = fBot.activeShell();
+ SWTBotButton button = shell2.bot().button("Overwrite All");
+ button.click();
+ }
fBot.waitUntil(Conditions.shellCloses(shell));
SWTBotUtils.waitForJobs();
}
/**
- * Gets the project Name
- * @return the project name
+ * Checks finish button enablement
+ *
+ * @param isEnabled
+ * state to check against
+ *
*/
- protected abstract String getProjectName();
+ protected void checkFinishButton(boolean isEnabled) {
+ final SWTBotButton finishButton = fBot.button("Finish");
+ assertTrue(finishButton.isEnabled() == isEnabled);
+ }
// ---------------------------------------------
// Helpers for testing views
/**
* Verifies the Histogram View
+ *
* @param vp
* the view part
* @param tmfEd
/**
* Verifies the statistics view
+ *
* @param vp
* the view part
*/
* @return the event at given rank
*/
protected CtfTmfEvent getEvent(int rank) {
- CtfTmfTrace trace = fTrace.getTrace();
- ITmfContext ctx = trace.seekEvent(0);
- for (int i = 0; i < rank; i++) {
- trace.getNext(ctx);
- }
+ CtfTmfTrace trace = CtfTmfTestTraceUtils.getTrace(fTrace);
+ ITmfContext ctx = trace.seekEvent(rank);
CtfTmfEvent ret = trace.getNext(ctx);
- trace.dispose();
+ ctx.dispose();
return ret;
}
/**
* Gets a view part based on view title
+ *
* @param viewTile
- * a view title
+ * a view title
* @return the view part
*/
protected IViewPart getViewPart(final String viewTile) {