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 / StandardImportAndReadSmokeTest.java
index 35c11d9efc373b76c1c832df3085ad91ad702746..da529b4703ce1dadd391362fc8ff679ddb8be4ce 100644 (file)
 
 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;
 import static org.junit.Assert.assertTrue;
 
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
@@ -34,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;
@@ -50,11 +56,15 @@ 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;
@@ -65,6 +75,8 @@ import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -76,9 +88,10 @@ import org.junit.runner.RunWith;
 @RunWith(SWTBotJunit4ClassRunner.class)
 public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTest {
 
-    private static final String TRACE_FOLDER_PARENT_PATH = fTrace.getPath() + File.separator + ".." + File.separator + ".." + File.separator;
+    private static final String TRACE_FOLDER_PARENT_PATH = "../../ctf/org.eclipse.tracecompass.ctf.core.tests/traces/";
     private static final String ARCHIVE_FILE_NAME = "synctraces.tar.gz";
     private static final String EMPTY_ARCHIVE_FOLDER = "emptyArchiveFolder";
+    private static final String EMPTY_FILE_NAME = "emptyFile";
     private static final String TRACE_ARCHIVE_PATH = TRACE_FOLDER_PARENT_PATH + ARCHIVE_FILE_NAME;
     private static final String TRACE_FOLDER_PARENT_NAME = "traces";
     private static final String TRACE_PROJECT_NAME = "Tracing";
@@ -91,6 +104,18 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
     private static final boolean IS_WIN32 = System.getProperty("os.name").startsWith("Windows");  //$NON-NLS-1$//$NON-NLS-2$
     private static final String URI_DEVICE_SEPARATOR = IS_WIN32 ? URI_SEPARATOR : "";
 
+    /** Test Class setup */
+    @BeforeClass
+    public static void beforeClass() {
+        createProject(TRACE_PROJECT_NAME);
+    }
+
+    /** Test Class tear down */
+    @AfterClass
+    public static void afterClass() {
+        SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot);
+    }
+
     /**
      * Test import from directory
      *
@@ -113,6 +138,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
      *
@@ -144,10 +191,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
      *
@@ -159,6 +230,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
@@ -176,7 +258,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);
     }
 
@@ -188,7 +270,7 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
      */
     @Test
     public void testExtractArchivesFromDirectory() throws Exception {
-        testImportAndExtractArchives(ImportTraceWizardPage.OPTION_OVERWRITE_EXISTING_RESOURCES, false);
+        testImportAndExtractArchives(ImportTraceWizardPage.OPTION_OVERWRITE_EXISTING_RESOURCES, false, false);
     }
 
     /**
@@ -197,7 +279,7 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
      */
     @Test
     public void testExtractArchivesFromDirectoryLinks() throws Exception {
-        testImportAndExtractArchives(ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE | ImportTraceWizardPage.OPTION_OVERWRITE_EXISTING_RESOURCES, false);
+        testImportAndExtractArchives(ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE | ImportTraceWizardPage.OPTION_OVERWRITE_EXISTING_RESOURCES, false, false);
     }
 
     /**
@@ -206,7 +288,7 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
      */
     @Test
     public void testExtractArchivesFromDirectoryLinksPreserveStruture() throws Exception {
-        testImportAndExtractArchives(ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE | ImportTraceWizardPage.OPTION_OVERWRITE_EXISTING_RESOURCES | ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE, false);
+        testImportAndExtractArchives(ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE | ImportTraceWizardPage.OPTION_OVERWRITE_EXISTING_RESOURCES | ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE, true, false);
     }
 
     /**
@@ -217,7 +299,7 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
      */
     @Test
     public void testExtractArchivesFromArchive() throws Exception {
-        testImportAndExtractArchives(ImportTraceWizardPage.OPTION_OVERWRITE_EXISTING_RESOURCES, true);
+        testImportAndExtractArchives(ImportTraceWizardPage.OPTION_OVERWRITE_EXISTING_RESOURCES, false, true);
     }
 
     /**
@@ -228,7 +310,7 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
      */
     @Test
     public void testExtractArchivesFromArchivePreserveFolder() throws Exception {
-        testImportAndExtractArchives(ImportTraceWizardPage.OPTION_OVERWRITE_EXISTING_RESOURCES | ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE, true);
+        testImportAndExtractArchives(ImportTraceWizardPage.OPTION_OVERWRITE_EXISTING_RESOURCES | ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE, false, true);
     }
 
     /**
@@ -239,7 +321,6 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
      */
     @Test
     public void testEmptyArchive() throws Exception {
-        createProject();
         String testArchivePath = createEmptyArchive();
 
         openImportWizard();
@@ -250,7 +331,8 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
 
         assertNoTraces();
 
-        SWTBotUtils.deleteProject(getProjectName(), fBot);
+        SWTBotUtils.clearTracesFolder(fBot, TRACE_PROJECT_NAME);
+        Files.delete(Paths.get(testArchivePath));
     }
 
     /**
@@ -261,8 +343,8 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
      */
     @Test
     public void testEmptyDirectory() throws Exception {
-        createProject();
-        String testDirectoryPath = createEmptyDirectory().getLocation().toOSString();
+        IFolder emptyDirectory = createEmptyDirectory();
+        String testDirectoryPath = emptyDirectory.getLocation().toOSString();
 
         openImportWizard();
         selectImportFromDirectory(testDirectoryPath);
@@ -272,7 +354,32 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
 
         assertNoTraces();
 
-        SWTBotUtils.deleteProject(getProjectName(), fBot);
+        Files.delete(Paths.get(testDirectoryPath));
+        emptyDirectory.delete(true, null);
+        SWTBotUtils.clearTracesFolder(fBot, TRACE_PROJECT_NAME);
+    }
+
+    /**
+     * Test import from an directory with an empty file. This should not import anything.
+     *
+     * @throws Exception
+     *             on error
+     */
+    @Test
+    public void testEmptyFile() throws Exception {
+        IFolder folder = createEmptyDirectory();
+        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);
+        importFinish();
+
+        assertNoTraces();
+
+        SWTBotUtils.clearTracesFolder(fBot, TRACE_PROJECT_NAME);
+        folder.delete(true, null);
     }
 
     /**
@@ -283,18 +390,18 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
      */
     @Test
     public void testDirectoryWithEmptyArchive() throws Exception {
-        createProject();
-        createEmptyArchive();
+        String testArchivePath = createEmptyArchive();
 
         openImportWizard();
         selectImportFromDirectory(getProjectResource().getLocation().toOSString());
-        selectFile(GENERATED_ARCHIVE_NAME, getProjectName());
+        selectFile(GENERATED_ARCHIVE_NAME, TRACE_PROJECT_NAME);
         setOptions(0, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
         importFinish();
 
         assertNoTraces();
 
-        SWTBotUtils.deleteProject(getProjectName(), fBot);
+        SWTBotUtils.clearTracesFolder(fBot, TRACE_PROJECT_NAME);
+        Files.delete(Paths.get(testArchivePath));
     }
 
     /**
@@ -305,7 +412,6 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
      */
     @Test
     public void testNestedEmptyArchive() throws Exception {
-        createProject();
         IProject project = getProjectResource();
 
         // Create the empty archive from an empty folder
@@ -321,6 +427,7 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         IFile renamedArchiveFile = archiveFile.getWorkspace().getRoot().getFile(dest);
 
         createArchive(renamedArchiveFile);
+        renamedArchiveFile.delete(true, null);
 
         openImportWizard();
         selectImportFromArchive(testArchivePath);
@@ -330,10 +437,11 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
 
         assertNoTraces();
 
-        SWTBotUtils.deleteProject(getProjectName(), fBot);
+        SWTBotUtils.clearTracesFolder(fBot, TRACE_PROJECT_NAME);
+        Files.delete(Paths.get(testArchivePath));
     }
 
-    private void assertNoTraces() {
+    private static void assertNoTraces() {
         TmfProjectElement tmfProject = TmfProjectRegistry.getProject(getProjectResource(), true);
         assertNotNull(tmfProject);
         TmfTraceFolder tracesFolder = tmfProject.getTracesFolder();
@@ -343,8 +451,23 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
     }
 
     private void testImport(int options, boolean testViews, boolean fromArchive) throws Exception {
-        createProject();
+        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;
@@ -360,31 +483,45 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         }
 
         setOptions(options, ImportTraceWizardPage.TRACE_TYPE_AUTO_DETECT);
-        importFinish();
+
+        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);
-        TmfEventsEditor tmfEd = SWTBotUtils.openEditor(fBot, getProjectName(), 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);
         }
 
         fBot.closeAllEditors();
 
-        SWTBotUtils.deleteProject(getProjectName(), fBot);
+        SWTBotUtils.clearExperimentFolder(fBot, TRACE_PROJECT_NAME);
+        if (clearTraces) {
+            SWTBotUtils.clearTracesFolder(fBot, TRACE_PROJECT_NAME);
+        }
     }
 
-    private void testImportAndExtractArchives(int options, boolean fromArchive) throws Exception {
-        createProject();
-
+    private void testImportAndExtractArchives(int options, boolean testViews, boolean fromArchive) throws Exception {
         String expectedSourceLocation;
         IPath expectedElementPath;
+        String testArchivePath = null;
         if (fromArchive) {
-            String testArchivePath = createNestedArchive();
+            testArchivePath = createNestedArchive();
             openImportWizard();
             selectImportFromArchive(testArchivePath);
             selectFile(ARCHIVE_FILE_NAME, ARCHIVE_ROOT_ELEMENT_NAME, TRACE_PROJECT_NAME, TRACE_FOLDER_PARENT_NAME);
@@ -411,16 +548,23 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         checkOptions(expectedOptions, expectedSourceLocation, expectedElementPath);
 
         TmfEventsEditor editor = SWTBotUtils.openEditor(fBot, TRACE_PROJECT_NAME, expectedElementPath);
-        testViews(editor);
+        if (testViews) {
+            testViews(editor);
+        }
 
-        SWTBotUtils.deleteProject(getProjectName(), fBot);
+        SWTBotUtils.clearExperimentFolder(fBot, TRACE_PROJECT_NAME);
+
+        SWTBotUtils.clearTracesFolder(fBot, TRACE_PROJECT_NAME);
+        if (testArchivePath != null) {
+            Files.delete(Paths.get(testArchivePath));
+        }
     }
 
     /**
      * Create a temporary archive containing a nested archive. For example,
      * testtraces.zip/synctraces.tar.gz can be used to test a nested archive.
      */
-    private String createNestedArchive() throws IOException, CoreException, URISyntaxException {
+    private static String createNestedArchive() throws IOException, CoreException, URISyntaxException {
         // Link to the test traces folder. We use a link so that we can safely
         // delete the entire project when we are done.
         IProject project = getProjectResource();
@@ -428,23 +572,34 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         IFolder folder = project.getFolder(TRACE_FOLDER_PARENT_NAME);
         folder.createLink(new Path(canonicalPath), IResource.REPLACE, null);
         IFile file = folder.getFile(ARCHIVE_FILE_NAME);
-        return createArchive(file);
+        String archivePath = createArchive(file);
+        folder.delete(true, null);
+        return archivePath;
     }
 
     /**
      * Create the empty archive from an empty folder
      */
-    private String createEmptyArchive() throws CoreException, URISyntaxException {
-        return createArchive(createEmptyDirectory());
+    private static String createEmptyArchive() throws CoreException, URISyntaxException {
+        IFolder tempEmptyDirectory = createEmptyDirectory();
+        String archivePath = createArchive(tempEmptyDirectory);
+        tempEmptyDirectory.delete(true, null);
+        return archivePath;
     }
 
-    private IFolder createEmptyDirectory() throws CoreException {
+    private static IFolder createEmptyDirectory() throws CoreException {
         IProject project = getProjectResource();
         IFolder folder = project.getFolder(EMPTY_ARCHIVE_FOLDER);
         folder.create(true, true, null);
         return folder;
     }
 
+    private static void createEmptyFile(IFolder folder) throws CoreException {
+        // Create empty file
+        IFile file = folder.getFile(EMPTY_FILE_NAME);
+        file.create(new ByteArrayInputStream(new byte[0]), true, null);
+    }
+
     /**
      * Create a temporary archive from the specified resource.
      */
@@ -461,6 +616,13 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         treeItem.select();
         fBot.button("Next >").click();
         fBot.button("&Deselect All").click();
+        try {
+            String resolveLinkedResLabel = "Resolve and export linked resources";
+            fBot.waitUntil(Conditions.waitForWidget(withMnemonic(resolveLinkedResLabel)), 100);
+            fBot.checkBox(resolveLinkedResLabel).select();
+        } catch (TimeoutException e) {
+            // Ignore, doesn't exist pre-4.6M5
+        }
 
         if (sourceResource instanceof IFile) {
             String[] folderPath = exportedPath.removeLastSegments(1).segments();
@@ -586,6 +748,13 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
             checkBox.deselect();
         }
 
+        checkBox = fBot.checkBox(Messages.ImportTraceWizard_CreateExperiment);
+        if ((optionFlags & ImportTraceWizardPage.OPTION_CREATE_EXPERIMENT) != 0) {
+            checkBox.select();
+        } else {
+            checkBox.deselect();
+        }
+
         SWTBotCombo comboBox = fBot.comboBoxWithLabel(Messages.ImportTraceWizard_TraceType);
         if (traceTypeName != null && !traceTypeName.isEmpty()) {
             comboBox.setSelection(traceTypeName);
@@ -594,7 +763,11 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         }
     }
 
-    private void checkOptions(int optionFlags, String expectedSourceLocation, IPath expectedElementPath) throws CoreException {
+    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, String experimentName, IPath expectedElementPathRenamed) throws CoreException {
         IProject project = getProjectResource();
         assertTrue(project.exists());
         TmfProjectElement tmfProject = TmfProjectRegistry.getProject(project, true);
@@ -619,17 +792,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);
+        }
     }
 
-    @Override
-    protected String getProjectName() {
-        return TRACE_PROJECT_NAME;
+    private static IProject getProjectResource() {
+        return ResourcesPlugin.getWorkspace().getRoot().getProject(TRACE_PROJECT_NAME);
     }
 
-    private IProject getProjectResource() {
-        return ResourcesPlugin.getWorkspace().getRoot().getProject(getProjectName());
+    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.031417 seconds and 5 git commands to generate.