Fix importing an archive containing colons (:) in the names on Windows
[deliverable/tracecompass.git] / ctf / org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests / src / org / eclipse / tracecompass / tmf / ctf / ui / swtbot / tests / StandardImportAndReadSmokeTest.java
index 7e6275e912315c80bef2450f6db66ea12d8b40ee..77916f0d606aef5744f3de869ba0a183f42d9cc0 100644 (file)
@@ -14,6 +14,7 @@
 package org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests;
 
 import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -38,6 +39,7 @@ import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.widgets.Shell;
@@ -46,20 +48,19 @@ import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
 import org.eclipse.swtbot.swt.finder.results.VoidResult;
 import org.eclipse.swtbot.swt.finder.waits.Conditions;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
+import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportConfirmation;
 import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportTraceWizard;
 import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportTraceWizardPage;
 import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.Messages;
 import org.eclipse.tracecompass.tmf.core.TmfCommonConstants;
 import org.eclipse.tracecompass.tmf.ui.editors.TmfEventsEditor;
+import org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement;
+import org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentFolder;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectElement;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement;
@@ -133,6 +134,28 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         testImport(ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE, false, false);
     }
 
+    /**
+     * Test import from directory, create experiment
+     *
+     * @throws Exception
+     *             on error
+     */
+    @Test
+    public void testImportWithExperiment() throws Exception {
+        testImport(ImportTraceWizardPage.OPTION_CREATE_EXPERIMENT, false, false);
+    }
+
+    /**
+     * Test import from directory, create experiment (validate experiment name)
+     *
+     * @throws Exception
+     *             on error
+     */
+    @Test
+    public void testImportWithExperimentValidation() throws Exception {
+        testImport(ImportTraceWizardPage.OPTION_CREATE_EXPERIMENT, false, false, false, true, ImportConfirmation.CONTINUE);
+    }
+
     /**
      * Test import from directory, preserve folder structure
      *
@@ -164,10 +187,34 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
      */
     @Test
     public void testImportFromDirectoryOverwrite() throws Exception {
-        testImport(0, false, false);
+        testImport(0, false, false, true, false, ImportConfirmation.CONTINUE);
         testImport(ImportTraceWizardPage.OPTION_OVERWRITE_EXISTING_RESOURCES, false, false);
     }
 
+    /**
+     * Test import from directory, overwrite all
+     *
+     * @throws Exception
+     *             on error
+     */
+    @Test
+    public void testImportFromDirectoryOverwriteRenameAll() throws Exception {
+        testImport(0, false, false, true, false, ImportConfirmation.CONTINUE);
+        testImport(0, false, false, true, true, ImportConfirmation.RENAME_ALL);
+    }
+
+    /**
+     * Test import from directory, overwrite all
+     *
+     * @throws Exception
+     *             on error
+     */
+    @Test
+    public void testImportFromDirectoryOverwriteOverwriteAll() throws Exception {
+        testImport(0, false, false, true, false, ImportConfirmation.CONTINUE);
+        testImport(0, false, false, true, true, ImportConfirmation.OVERWRITE_ALL);
+    }
+
     /**
      * Test import from archive
      *
@@ -179,6 +226,17 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         testImport(ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE, true, true);
     }
 
+    /**
+     * Test import from archive, create Experiment
+     *
+     * @throws Exception
+     *             on error
+     */
+    @Test
+    public void testImportFromArchiveWithExperiment() throws Exception {
+        testImport(ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE | ImportTraceWizardPage.OPTION_CREATE_EXPERIMENT, false, true);
+    }
+
     /**
      * Test import from directory, preserve folder structure
      * @throws Exception on error
@@ -196,7 +254,7 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
      */
     @Test
     public void testImportFromArchiveOverwrite() throws Exception {
-        testImport(0, false, true);
+        testImport(0, false, true, true, false, ImportConfirmation.CONTINUE);
         testImport(ImportTraceWizardPage.OPTION_OVERWRITE_EXISTING_RESOURCES, false, true);
     }
 
@@ -262,9 +320,9 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         String testArchivePath = createEmptyArchive();
 
         openImportWizard();
-        selectImportFromArchive(testArchivePath);
+        SWTBotImportWizardUtils.selectImportFromArchive(fBot, testArchivePath);
         selectFolder(ARCHIVE_ROOT_ELEMENT_NAME);
-        setOptions(0, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
+        SWTBotImportWizardUtils.setOptions(fBot, 0, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
         importFinish();
 
         assertNoTraces();
@@ -285,9 +343,9 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         String testDirectoryPath = emptyDirectory.getLocation().toOSString();
 
         openImportWizard();
-        selectImportFromDirectory(testDirectoryPath);
+        SWTBotImportWizardUtils.selectImportFromDirectory(fBot, testDirectoryPath);
         selectFolder(EMPTY_ARCHIVE_FOLDER);
-        setOptions(0, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
+        SWTBotImportWizardUtils.setOptions(fBot, 0, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
         importFinish();
 
         assertNoTraces();
@@ -309,9 +367,9 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         createEmptyFile(folder);
         String testDirectoryPath = folder.getLocation().toOSString();
         openImportWizard();
-        selectImportFromDirectory(testDirectoryPath);
-        selectFile(EMPTY_FILE_NAME, EMPTY_ARCHIVE_FOLDER);
-        setOptions(ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
+        SWTBotImportWizardUtils.selectImportFromDirectory(fBot, testDirectoryPath);
+        SWTBotImportWizardUtils.selectFile(fBot, EMPTY_FILE_NAME, EMPTY_ARCHIVE_FOLDER);
+        SWTBotImportWizardUtils.setOptions(fBot, ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
         importFinish();
 
         assertNoTraces();
@@ -331,9 +389,9 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         String testArchivePath = createEmptyArchive();
 
         openImportWizard();
-        selectImportFromDirectory(getProjectResource().getLocation().toOSString());
-        selectFile(GENERATED_ARCHIVE_NAME, TRACE_PROJECT_NAME);
-        setOptions(0, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
+        SWTBotImportWizardUtils.selectImportFromDirectory(fBot, getProjectResource().getLocation().toOSString());
+        SWTBotImportWizardUtils.selectFile(fBot, GENERATED_ARCHIVE_NAME, TRACE_PROJECT_NAME);
+        SWTBotImportWizardUtils.setOptions(fBot, 0, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
         importFinish();
 
         assertNoTraces();
@@ -368,9 +426,9 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         renamedArchiveFile.delete(true, null);
 
         openImportWizard();
-        selectImportFromArchive(testArchivePath);
+        SWTBotImportWizardUtils.selectImportFromArchive(fBot, testArchivePath);
         selectFolder(ARCHIVE_ROOT_ELEMENT_NAME);
-        setOptions(0, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
+        SWTBotImportWizardUtils.setOptions(fBot, 0, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
         importFinish();
 
         assertNoTraces();
@@ -379,6 +437,34 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         Files.delete(Paths.get(testArchivePath));
     }
 
+    /**
+     * Test importing an archive with colons in the names. Those are invalid
+     * characters in Windows paths so this test makes sure that they are
+     * replaced properly with '_'
+     */
+    @Test
+    public void testArchiveWithColons() {
+        openImportWizard();
+        IPath absolutePath = Activator.getAbsolutePath(new Path("testfiles/testcolon.zip"));
+
+        SWTBotImportWizardUtils.selectImportFromArchive(fBot, absolutePath.toOSString());
+        String subFolderName = IS_WIN32 ? "folder_colon" : "folder:colon";
+        selectFolder(ARCHIVE_ROOT_ELEMENT_NAME, subFolderName);
+        SWTBotImportWizardUtils.setOptions(fBot, 0, "Test trace : XML Trace Stub");
+        importFinish();
+
+        TmfProjectElement tmfProject = TmfProjectRegistry.getProject(getProjectResource(), true);
+        assertNotNull(tmfProject);
+        TmfTraceFolder tracesFolder = tmfProject.getTracesFolder();
+        assertNotNull(tracesFolder);
+        List<TmfTraceElement> traces = tracesFolder.getTraces();
+        assertTrue(traces.size() == 1);
+        String traceName = IS_WIN32 ? "trace_colon.xml" : "trace:colon.xml";
+        assertEquals(traceName, traces.get(0).getName());
+
+        SWTBotUtils.clearTracesFolder(fBot, TRACE_PROJECT_NAME);
+    }
+
     private static void assertNoTraces() {
         TmfProjectElement tmfProject = TmfProjectRegistry.getProject(getProjectResource(), true);
         assertNotNull(tmfProject);
@@ -389,30 +475,58 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
     }
 
     private void testImport(int options, boolean testViews, boolean fromArchive) throws Exception {
+        testImport(options, testViews, fromArchive, true, true, ImportConfirmation.CONTINUE);
+    }
+
+    private void testImport(int options, boolean testViews, boolean fromArchive, boolean defaultExperiment, boolean clearTraces, ImportConfirmation confirmationMode) throws Exception {
         String expectedSourceLocation = null;
+
+        @NonNull String experimentName;
+        if (fromArchive) {
+            experimentName = checkNotNull(new Path(ARCHIVE_FILE_NAME).lastSegment());
+        } else {
+            experimentName = checkNotNull(new Path(TRACE_FOLDER_PARENT_PATH).lastSegment());
+        }
+
+        if (!defaultExperiment) {
+            SWTBotUtils.createExperiment(fBot, TRACE_PROJECT_NAME, experimentName);
+        }
+
         openImportWizard();
         if (fromArchive) {
             expectedSourceLocation = URI_JAR_FILE_SCHEME + URI_DEVICE_SEPARATOR + new Path(new File(TRACE_ARCHIVE_PATH).getCanonicalPath()) + "!" + URI_SEPARATOR + TRACE_FOLDER + URI_SEPARATOR + TRACE_NAME + URI_SEPARATOR;
-            selectImportFromArchive(TRACE_ARCHIVE_PATH);
+            SWTBotImportWizardUtils.selectImportFromArchive(fBot, TRACE_ARCHIVE_PATH);
             selectFolder(ARCHIVE_ROOT_ELEMENT_NAME);
             SWTBotCheckBox checkBox = fBot.checkBox(Messages.ImportTraceWizard_CreateLinksInWorkspace);
             assertFalse(checkBox.isEnabled());
         } else {
             String sourcePath = TRACE_FOLDER_PARENT_PATH + File.separator + TRACE_FOLDER + File.separator + TRACE_NAME;
             expectedSourceLocation = URI_FILE_SCHEME + URI_DEVICE_SEPARATOR + new Path(new File(sourcePath).getCanonicalPath()) + URI_SEPARATOR;
-            selectImportFromDirectory(TRACE_FOLDER_PARENT_PATH);
+            SWTBotImportWizardUtils.selectImportFromDirectory(fBot, TRACE_FOLDER_PARENT_PATH);
             selectFolder(new String [] {TRACE_FOLDER_PARENT_NAME, TRACE_FOLDER });
         }
 
-        setOptions(options, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
-        importFinish();
+        SWTBotImportWizardUtils.setOptions(fBot, options, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
+
+        if (!defaultExperiment) {
+            experimentName = verifyExperimentNameHandling(experimentName);
+        }
+        checkFinishButton(true);
+
+        importFinish(confirmationMode);
 
         IPath expectedElementPath = new Path(TRACE_NAME);
         if ((options & ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE) != 0) {
             expectedElementPath = new Path(TRACE_FOLDER).append(expectedElementPath);
         }
 
-        checkOptions(options, expectedSourceLocation, expectedElementPath);
+        if (confirmationMode == ImportConfirmation.RENAME_ALL) {
+            IPath expectedElementPathRenamed = new Path(TRACE_NAME + "(2)");
+            checkOptions(options, expectedSourceLocation, expectedElementPath, experimentName, expectedElementPathRenamed);
+        } else {
+            checkOptions(options, expectedSourceLocation, expectedElementPath, experimentName, null);
+        }
+
         TmfEventsEditor tmfEd = SWTBotUtils.openEditor(fBot, TRACE_PROJECT_NAME, expectedElementPath);
         if (testViews) {
             testViews(tmfEd);
@@ -420,7 +534,10 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
 
         fBot.closeAllEditors();
 
-        SWTBotUtils.clearTracesFolder(fBot, TRACE_PROJECT_NAME);
+        SWTBotUtils.clearExperimentFolder(fBot, TRACE_PROJECT_NAME);
+        if (clearTraces) {
+            SWTBotUtils.clearTracesFolder(fBot, TRACE_PROJECT_NAME);
+        }
     }
 
     private void testImportAndExtractArchives(int options, boolean testViews, boolean fromArchive) throws Exception {
@@ -430,16 +547,16 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         if (fromArchive) {
             testArchivePath = createNestedArchive();
             openImportWizard();
-            selectImportFromArchive(testArchivePath);
-            selectFile(ARCHIVE_FILE_NAME, ARCHIVE_ROOT_ELEMENT_NAME, TRACE_PROJECT_NAME, TRACE_FOLDER_PARENT_NAME);
+            SWTBotImportWizardUtils.selectImportFromArchive(fBot, testArchivePath);
+            SWTBotImportWizardUtils.selectFile(fBot, ARCHIVE_FILE_NAME, ARCHIVE_ROOT_ELEMENT_NAME, TRACE_PROJECT_NAME, TRACE_FOLDER_PARENT_NAME);
 
             expectedSourceLocation = URI_JAR_FILE_SCHEME + URI_DEVICE_SEPARATOR + new Path(new File(testArchivePath).getCanonicalPath()) + "!" + URI_SEPARATOR + TRACE_PROJECT_NAME + URI_SEPARATOR + TRACE_FOLDER_PARENT_NAME + URI_SEPARATOR + ARCHIVE_FILE_NAME
                     + URI_SEPARATOR + TRACE_FOLDER + URI_SEPARATOR + TRACE_NAME + URI_SEPARATOR;
             expectedElementPath = new Path(TRACE_PROJECT_NAME).append(TRACE_FOLDER_PARENT_NAME).append(ARCHIVE_FILE_NAME).append(TRACE_FOLDER).append(TRACE_NAME);
         } else {
             openImportWizard();
-            selectImportFromDirectory(TRACE_FOLDER_PARENT_PATH);
-            selectFile(ARCHIVE_FILE_NAME, TRACE_FOLDER_PARENT_NAME);
+            SWTBotImportWizardUtils.selectImportFromDirectory(fBot, TRACE_FOLDER_PARENT_PATH);
+            SWTBotImportWizardUtils.selectFile(fBot, ARCHIVE_FILE_NAME, TRACE_FOLDER_PARENT_NAME);
             expectedElementPath = new Path(ARCHIVE_FILE_NAME).append(TRACE_FOLDER).append(TRACE_NAME);
             expectedSourceLocation = URI_FILE_SCHEME + URI_DEVICE_SEPARATOR + new Path(new File(TRACE_FOLDER_PARENT_PATH).getCanonicalPath()) + URI_SEPARATOR + ARCHIVE_FILE_NAME + URI_SEPARATOR + TRACE_FOLDER + URI_SEPARATOR + TRACE_NAME + URI_SEPARATOR;
         }
@@ -448,7 +565,7 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
             expectedElementPath = new Path(TRACE_NAME);
         }
 
-        setOptions(options, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
+        SWTBotImportWizardUtils.setOptions(fBot, options, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
         importFinish();
         // Archives should never be imported as links
         int expectedOptions = options & ~ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
@@ -459,6 +576,8 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
             testViews(editor);
         }
 
+        SWTBotUtils.clearExperimentFolder(fBot, TRACE_PROJECT_NAME);
+
         SWTBotUtils.clearTracesFolder(fBot, TRACE_PROJECT_NAME);
         if (testArchivePath != null) {
             Files.delete(Paths.get(testArchivePath));
@@ -532,7 +651,7 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         if (sourceResource instanceof IFile) {
             String[] folderPath = exportedPath.removeLastSegments(1).segments();
             String fileName = exportedPath.lastSegment();
-            selectFile(fileName, folderPath);
+            SWTBotImportWizardUtils.selectFile(fBot, fileName, folderPath);
         } else {
             selectFolder(exportedPath.segments());
         }
@@ -573,95 +692,17 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         fBot.waitUntil(ConditionHelpers.isWizardReady(fWizard));
     }
 
-    private static void selectImportFromDirectory(String directoryPath) {
-        SWTBotRadio button = fBot.radio("Select roo&t directory:");
-        button.click();
-
-        SWTBotCombo sourceCombo = fBot.comboBox();
-        File traceFolderParent = new File(directoryPath);
-        sourceCombo.setText(traceFolderParent.getAbsolutePath());
-
-        SWTBotText text = fBot.text();
-        text.setFocus();
-    }
-
-    private static void selectImportFromArchive(String archivePath) {
-        SWTBotRadio button = fBot.radio("Select &archive file:");
-        button.click();
-
-        SWTBotCombo sourceCombo = fBot.comboBox(1);
 
-        sourceCombo.setText(new File(archivePath).getAbsolutePath());
-
-        SWTBotText text = fBot.text();
-        text.setFocus();
-    }
 
     private static void selectFolder(String... treePath) {
-        selectFolder(true, treePath);
-    }
-
-    private static void selectFolder(boolean check, String... treePath) {
-        SWTBotTree tree = fBot.tree();
-        fBot.waitUntil(Conditions.widgetIsEnabled(tree));
-        SWTBotTreeItem folderNode = SWTBotUtils.getTreeItem(fBot, tree, treePath);
-        if (check) {
-            folderNode.check();
-        } else {
-            folderNode.select();
-        }
-    }
-
-    private static void selectFile(String fileName, String... folderTreePath) {
-        selectFolder(false, folderTreePath);
-
-        SWTBotTable fileTable = fBot.table();
-        fBot.waitUntil(Conditions.widgetIsEnabled(fileTable));
-        fBot.waitUntil(ConditionHelpers.isTableItemAvailable(fileName, fileTable));
-        SWTBotTableItem tableItem = fileTable.getTableItem(fileName);
-        tableItem.check();
+        SWTBotImportWizardUtils.selectFolder(fBot, true, treePath);
     }
 
-    private static void setOptions(int optionFlags, String traceTypeName) {
-        SWTBotCheckBox checkBox = fBot.checkBox(Messages.ImportTraceWizard_CreateLinksInWorkspace);
-        if (checkBox.isEnabled()) {
-            if ((optionFlags & ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE) != 0) {
-                checkBox.select();
-            } else {
-                checkBox.deselect();
-            }
-        }
-
-        checkBox = fBot.checkBox(Messages.ImportTraceWizard_PreserveFolderStructure);
-        if ((optionFlags & ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE) != 0) {
-            checkBox.select();
-        } else {
-            checkBox.deselect();
-        }
-
-        checkBox = fBot.checkBox(Messages.ImportTraceWizard_ImportUnrecognized);
-        if ((optionFlags & ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES) != 0) {
-            checkBox.select();
-        } else {
-            checkBox.deselect();
-        }
-
-        checkBox = fBot.checkBox(Messages.ImportTraceWizard_OverwriteExistingTrace);
-        if ((optionFlags & ImportTraceWizardPage.OPTION_OVERWRITE_EXISTING_RESOURCES) != 0) {
-            checkBox.select();
-        } else {
-            checkBox.deselect();
-        }
-
-        SWTBotCombo comboBox = fBot.comboBoxWithLabel(Messages.ImportTraceWizard_TraceType);
-        if (traceTypeName != null && !traceTypeName.isEmpty()) {
-            comboBox.setSelection(traceTypeName);
-        } else {
-            comboBox.setSelection(ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
-        }
+    private static void checkOptions(int optionFlags, String expectedSourceLocation, IPath expectedElementPath) throws CoreException {
+        checkOptions(optionFlags, expectedSourceLocation, expectedElementPath, null, null);
     }
 
-    private static void checkOptions(int optionFlags, String expectedSourceLocation, IPath expectedElementPath) throws CoreException {
+    private static void checkOptions(int optionFlags, String expectedSourceLocation, IPath expectedElementPath, String experimentName, IPath expectedElementPathRenamed) throws CoreException {
         IProject project = getProjectResource();
         assertTrue(project.exists());
         TmfProjectElement tmfProject = TmfProjectRegistry.getProject(project, true);
@@ -686,12 +727,53 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         IPath expectedPath = Path.ROOT.append(new Path(TRACE_PROJECT_NAME)).append(TmfTracesFolder.TRACES_FOLDER_NAME).append(expectedElementPath);
         assertEquals(expectedPath, traceResource.getFullPath());
 
+        if (expectedElementPathRenamed != null) {
+            IPath expectedPathRenamed = Path.ROOT.append(new Path(TRACE_PROJECT_NAME)).append(TmfTracesFolder.TRACES_FOLDER_NAME).append(expectedElementPathRenamed);
+            IResource traceResourceRenamed = traces.get(1).getResource();
+            assertEquals(expectedPathRenamed, traceResourceRenamed.getFullPath());
+        }
+
         String sourceLocation = traceResource.getPersistentProperty(TmfCommonConstants.SOURCE_LOCATION);
         assertNotNull(sourceLocation);
         assertEquals(expectedSourceLocation, sourceLocation);
+
+        TmfExperimentFolder expFolder = tmfProject.getExperimentsFolder();
+        assertNotNull(expFolder);
+        if ((optionFlags & ImportTraceWizardPage.OPTION_CREATE_EXPERIMENT) != 0) {
+            if (experimentName != null) {
+                TmfExperimentElement expElement = expFolder.getExperiment(experimentName);
+                assertNotNull(expElement);
+                assertEquals(2, expElement.getTraces().size());
+            }
+        } else {
+            assertTrue(expFolder.getExperiments().size() == 0);
+        }
     }
 
     private static IProject getProjectResource() {
         return ResourcesPlugin.getWorkspace().getRoot().getProject(TRACE_PROJECT_NAME);
     }
+
+    private @NonNull String verifyExperimentNameHandling(String aExperimentName) {
+        String experimentName = aExperimentName;
+
+        // experiment already exists
+        checkFinishButton(false);
+
+        SWTBotText expText = fBot.textInGroup("Options");
+
+        // Invalid experiment name (only whitespaces)
+        expText.setText(String.valueOf(' '));
+        checkFinishButton(false);
+
+        // Invalid experiment name
+        expText.setText(String.valueOf('/'));
+        checkFinishButton(false);
+
+        // Set valid experiment name
+        experimentName += '_';
+        expText.setText(experimentName);
+        return experimentName;
+    }
+
 }
This page took 0.03479 seconds and 5 git commands to generate.