tmf: Bug 494689: fix failing name conflict handling in trace import
[deliverable/tracecompass.git] / ctf / org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests / src / org / eclipse / tracecompass / tmf / ctf / ui / swtbot / tests / AbstractImportAndReadSmokeTest.java
index 08480979f3f72c99a4cb95345a6fd589798b14d0..204fef13e81d7dab7484dad7443b88341114f49d 100644 (file)
@@ -14,6 +14,7 @@
 package org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests;
 
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.List;
 
@@ -36,6 +37,7 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
 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;
@@ -108,8 +110,11 @@ public abstract class AbstractImportAndReadSmokeTest {
 
     /**
      * 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();
 
@@ -135,7 +140,7 @@ public abstract class AbstractImportAndReadSmokeTest {
         fBot.shell("Tracing Project").setFocus();
 
         final SWTBotText text = fBot.text();
-        text.setText(getProjectName());
+        text.setText(traceProjectName);
 
         fBot.button("Finish").click();
         SWTBotUtils.waitForJobs();
@@ -145,19 +150,48 @@ public abstract class AbstractImportAndReadSmokeTest {
      * 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
+     * Checks finish button enablement
+     *
+     * @param isEnabled
+     *            state to check against
      *
-     * @return the project name
      */
-    protected abstract String getProjectName();
+    protected void checkFinishButton(boolean isEnabled) {
+        final SWTBotButton finishButton = fBot.button("Finish");
+        assertTrue(finishButton.isEnabled() == isEnabled);
+    }
 
     // ---------------------------------------------
     // Helpers for testing views
This page took 0.026073 seconds and 5 git commands to generate.