1 /*******************************************************************************
2 * Copyright (c) 2014, 2015 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 * Marc-Andre Laperle - Added tests for extracting archives during import
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.tmf
.ctf
.ui
.swtbot
.tests
;
16 import static org
.junit
.Assert
.assertEquals
;
17 import static org
.junit
.Assert
.assertFalse
;
18 import static org
.junit
.Assert
.assertNotNull
;
19 import static org
.junit
.Assert
.assertTrue
;
21 import java
.io
.ByteArrayInputStream
;
23 import java
.io
.IOException
;
24 import java
.net
.URISyntaxException
;
25 import java
.util
.Collections
;
26 import java
.util
.Comparator
;
27 import java
.util
.List
;
29 import org
.eclipse
.core
.resources
.IFile
;
30 import org
.eclipse
.core
.resources
.IFolder
;
31 import org
.eclipse
.core
.resources
.IProject
;
32 import org
.eclipse
.core
.resources
.IResource
;
33 import org
.eclipse
.core
.resources
.ResourcesPlugin
;
34 import org
.eclipse
.core
.runtime
.CoreException
;
35 import org
.eclipse
.core
.runtime
.IPath
;
36 import org
.eclipse
.core
.runtime
.Path
;
37 import org
.eclipse
.core
.runtime
.URIUtil
;
38 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
39 import org
.eclipse
.jface
.wizard
.WizardDialog
;
40 import org
.eclipse
.swt
.widgets
.Shell
;
41 import org
.eclipse
.swtbot
.swt
.finder
.finders
.UIThreadRunnable
;
42 import org
.eclipse
.swtbot
.swt
.finder
.junit
.SWTBotJunit4ClassRunner
;
43 import org
.eclipse
.swtbot
.swt
.finder
.results
.VoidResult
;
44 import org
.eclipse
.swtbot
.swt
.finder
.waits
.Conditions
;
45 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotCheckBox
;
46 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotCombo
;
47 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotRadio
;
48 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotShell
;
49 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTable
;
50 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTableItem
;
51 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotText
;
52 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTree
;
53 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTreeItem
;
54 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
.ImportTraceWizard
;
55 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
.ImportTraceWizardPage
;
56 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
.Messages
;
57 import org
.eclipse
.tracecompass
.tmf
.core
.TmfCommonConstants
;
58 import org
.eclipse
.tracecompass
.tmf
.ui
.editors
.TmfEventsEditor
;
59 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfProjectElement
;
60 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfProjectRegistry
;
61 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfTraceElement
;
62 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfTraceFolder
;
63 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfTracesFolder
;
64 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.ConditionHelpers
;
65 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.SWTBotUtils
;
66 import org
.eclipse
.ui
.IWorkbench
;
67 import org
.eclipse
.ui
.IWorkbenchWindow
;
68 import org
.eclipse
.ui
.PlatformUI
;
69 import org
.junit
.Test
;
70 import org
.junit
.runner
.RunWith
;
73 * SWTBot Smoke test using ImportTraceWizard.
75 * @author Bernd Hufmann
77 @RunWith(SWTBotJunit4ClassRunner
.class)
78 public class StandardImportAndReadSmokeTest
extends AbstractImportAndReadSmokeTest
{
80 private static final String TRACE_FOLDER_PARENT_PATH
= fTrace
.getPath() + File
.separator
+ ".." + File
.separator
+ ".." + File
.separator
;
81 private static final String ARCHIVE_FILE_NAME
= "synctraces.tar.gz";
82 private static final String EMPTY_ARCHIVE_FOLDER
= "emptyArchiveFolder";
83 private static final String EMPTY_FILE_NAME
= "emptyFile";
84 private static final String TRACE_ARCHIVE_PATH
= TRACE_FOLDER_PARENT_PATH
+ ARCHIVE_FILE_NAME
;
85 private static final String TRACE_FOLDER_PARENT_NAME
= "traces";
86 private static final String TRACE_PROJECT_NAME
= "Tracing";
88 private static final String ARCHIVE_ROOT_ELEMENT_NAME
= "/";
89 private static final String GENERATED_ARCHIVE_NAME
= "testtraces.zip";
90 private static final String URI_SEPARATOR
= "/";
91 private static final String URI_FILE_SCHEME
= "file:";
92 private static final String URI_JAR_FILE_SCHEME
= "jar:file:";
93 private static final boolean IS_WIN32
= System
.getProperty("os.name").startsWith("Windows"); //$NON-NLS-1$//$NON-NLS-2$
94 private static final String URI_DEVICE_SEPARATOR
= IS_WIN32 ? URI_SEPARATOR
: "";
97 * Test import from directory
103 public void testImportFromDirectory() throws Exception
{
104 testImport(0, false, false);
108 * Test import from directory, create links
114 public void testImportFromDirectoryLinks() throws Exception
{
115 testImport(ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
, false, false);
119 * Test import from directory, preserve folder structure
125 public void testImportFromDirectoryPreserveFolder() throws Exception
{
126 testImport(ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
, false, false);
130 * Test import from directory, create links, preserve folder structure
136 public void testImportFromDirectoryLinksPreserveFolder() throws Exception
{
137 int options
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
138 testImport(options
, false, false);
142 * Test import from directory, overwrite all
148 public void testImportFromDirectoryOverwrite() throws Exception
{
149 testImport(0, false, false);
150 testImport(ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
, false, false);
154 * Test import from archive
160 public void testImportFromArchive() throws Exception
{
161 testImport(ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
, true, true);
165 * Test import from directory, preserve folder structure
166 * @throws Exception on error
169 public void testImportFromArchivePreserveFolder() throws Exception
{
170 testImport(ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
, false, true);
174 * Test import from directory, overwrite all
180 public void testImportFromArchiveOverwrite() throws Exception
{
181 testImport(0, false, true);
182 testImport(ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
, false, true);
186 * Test import from directory containing archives
192 public void testExtractArchivesFromDirectory() throws Exception
{
193 testImportAndExtractArchives(ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
, false);
197 * Test import from directory containing archives, create links
198 * @throws Exception on error
201 public void testExtractArchivesFromDirectoryLinks() throws Exception
{
202 testImportAndExtractArchives(ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
, false);
206 * Test import from directory containing archives, create links, preserve folder structure
207 * @throws Exception on error
210 public void testExtractArchivesFromDirectoryLinksPreserveStruture() throws Exception
{
211 testImportAndExtractArchives(ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
, false);
215 * Test import from archive containing archives
221 public void testExtractArchivesFromArchive() throws Exception
{
222 testImportAndExtractArchives(ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
, true);
226 * Test import from archive containing archives, preserve folder structure
232 public void testExtractArchivesFromArchivePreserveFolder() throws Exception
{
233 testImportAndExtractArchives(ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
, true);
237 * Test import from an empty archive. This should not import anything.
243 public void testEmptyArchive() throws Exception
{
245 String testArchivePath
= createEmptyArchive();
248 selectImportFromArchive(testArchivePath
);
249 selectFolder(ARCHIVE_ROOT_ELEMENT_NAME
);
250 setOptions(0, ImportTraceWizardPage
.TRACE_TYPE_AUTO_DETECT
);
255 SWTBotUtils
.deleteProject(getProjectName(), fBot
);
259 * Test import from an empty directory. This should not import anything.
265 public void testEmptyDirectory() throws Exception
{
267 String testDirectoryPath
= createEmptyDirectory().getLocation().toOSString();
270 selectImportFromDirectory(testDirectoryPath
);
271 selectFolder(EMPTY_ARCHIVE_FOLDER
);
272 setOptions(0, ImportTraceWizardPage
.TRACE_TYPE_AUTO_DETECT
);
277 SWTBotUtils
.deleteProject(getProjectName(), fBot
);
281 * Test import from an directory with an empty file. This should not import anything.
287 public void testEmptyFile() throws Exception
{
289 IFolder folder
= createEmptyDirectory();
290 createEmptyFile(folder
);
291 String testDirectoryPath
= folder
.getLocation().toOSString();
293 selectImportFromDirectory(testDirectoryPath
);
294 selectFile(EMPTY_FILE_NAME
, EMPTY_ARCHIVE_FOLDER
);
295 setOptions(ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
, ImportTraceWizardPage
.TRACE_TYPE_AUTO_DETECT
);
300 SWTBotUtils
.deleteProject(getProjectName(), fBot
);
304 * Test import from a directory containing an empty archive. This should not import anything.
310 public void testDirectoryWithEmptyArchive() throws Exception
{
312 createEmptyArchive();
315 selectImportFromDirectory(getProjectResource().getLocation().toOSString());
316 selectFile(GENERATED_ARCHIVE_NAME
, getProjectName());
317 setOptions(0, ImportTraceWizardPage
.TRACE_TYPE_AUTO_DETECT
);
322 SWTBotUtils
.deleteProject(getProjectName(), fBot
);
326 * Test import from a nested empty archive. This should not import anything.
332 public void testNestedEmptyArchive() throws Exception
{
334 IProject project
= getProjectResource();
336 // Create the empty archive from an empty folder
337 String testArchivePath
= createEmptyArchive();
339 // Rename archive so that we can create a new one with the same name
340 project
.refreshLocal(IResource
.DEPTH_ONE
, null);
341 IFile
[] files
= project
.getWorkspace().getRoot().findFilesForLocationURI(new File(testArchivePath
).toURI());
342 IFile archiveFile
= files
[0];
343 String newEmptyArchiveName
= "nested" + archiveFile
.getName();
344 IPath dest
= archiveFile
.getFullPath().removeLastSegments(1).append(newEmptyArchiveName
);
345 archiveFile
.move(dest
, true, null);
346 IFile renamedArchiveFile
= archiveFile
.getWorkspace().getRoot().getFile(dest
);
348 createArchive(renamedArchiveFile
);
351 selectImportFromArchive(testArchivePath
);
352 selectFolder(ARCHIVE_ROOT_ELEMENT_NAME
);
353 setOptions(0, ImportTraceWizardPage
.TRACE_TYPE_AUTO_DETECT
);
358 SWTBotUtils
.deleteProject(getProjectName(), fBot
);
361 private void assertNoTraces() {
362 TmfProjectElement tmfProject
= TmfProjectRegistry
.getProject(getProjectResource(), true);
363 assertNotNull(tmfProject
);
364 TmfTraceFolder tracesFolder
= tmfProject
.getTracesFolder();
365 assertNotNull(tracesFolder
);
366 List
<TmfTraceElement
> traces
= tracesFolder
.getTraces();
367 assertTrue(traces
.isEmpty());
370 private void testImport(int options
, boolean testViews
, boolean fromArchive
) throws Exception
{
372 String expectedSourceLocation
= null;
375 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
;
376 selectImportFromArchive(TRACE_ARCHIVE_PATH
);
377 selectFolder(ARCHIVE_ROOT_ELEMENT_NAME
);
378 SWTBotCheckBox checkBox
= fBot
.checkBox(Messages
.ImportTraceWizard_CreateLinksInWorkspace
);
379 assertFalse(checkBox
.isEnabled());
381 String sourcePath
= TRACE_FOLDER_PARENT_PATH
+ File
.separator
+ TRACE_FOLDER
+ File
.separator
+ TRACE_NAME
;
382 expectedSourceLocation
= URI_FILE_SCHEME
+ URI_DEVICE_SEPARATOR
+ new Path(new File(sourcePath
).getCanonicalPath()) + URI_SEPARATOR
;
383 selectImportFromDirectory(TRACE_FOLDER_PARENT_PATH
);
384 selectFolder(new String
[] {TRACE_FOLDER_PARENT_NAME
, TRACE_FOLDER
});
387 setOptions(options
, ImportTraceWizardPage
.TRACE_TYPE_AUTO_DETECT
);
390 IPath expectedElementPath
= new Path(TRACE_NAME
);
391 if ((options
& ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
) != 0) {
392 expectedElementPath
= new Path(TRACE_FOLDER
).append(expectedElementPath
);
395 checkOptions(options
, expectedSourceLocation
, expectedElementPath
);
396 TmfEventsEditor tmfEd
= SWTBotUtils
.openEditor(fBot
, getProjectName(), expectedElementPath
);
401 fBot
.closeAllEditors();
403 SWTBotUtils
.deleteProject(getProjectName(), fBot
);
406 private void testImportAndExtractArchives(int options
, boolean fromArchive
) throws Exception
{
409 String expectedSourceLocation
;
410 IPath expectedElementPath
;
412 String testArchivePath
= createNestedArchive();
414 selectImportFromArchive(testArchivePath
);
415 selectFile(ARCHIVE_FILE_NAME
, ARCHIVE_ROOT_ELEMENT_NAME
, TRACE_PROJECT_NAME
, TRACE_FOLDER_PARENT_NAME
);
417 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
418 + URI_SEPARATOR
+ TRACE_FOLDER
+ URI_SEPARATOR
+ TRACE_NAME
+ URI_SEPARATOR
;
419 expectedElementPath
= new Path(TRACE_PROJECT_NAME
).append(TRACE_FOLDER_PARENT_NAME
).append(ARCHIVE_FILE_NAME
).append(TRACE_FOLDER
).append(TRACE_NAME
);
422 selectImportFromDirectory(TRACE_FOLDER_PARENT_PATH
);
423 selectFile(ARCHIVE_FILE_NAME
, TRACE_FOLDER_PARENT_NAME
);
424 expectedElementPath
= new Path(ARCHIVE_FILE_NAME
).append(TRACE_FOLDER
).append(TRACE_NAME
);
425 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
;
428 if ((options
& ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
) == 0) {
429 expectedElementPath
= new Path(TRACE_NAME
);
432 setOptions(options
, ImportTraceWizardPage
.TRACE_TYPE_AUTO_DETECT
);
434 // Archives should never be imported as links
435 int expectedOptions
= options
& ~ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
436 checkOptions(expectedOptions
, expectedSourceLocation
, expectedElementPath
);
438 TmfEventsEditor editor
= SWTBotUtils
.openEditor(fBot
, TRACE_PROJECT_NAME
, expectedElementPath
);
441 SWTBotUtils
.deleteProject(getProjectName(), fBot
);
445 * Create a temporary archive containing a nested archive. For example,
446 * testtraces.zip/synctraces.tar.gz can be used to test a nested archive.
448 private String
createNestedArchive() throws IOException
, CoreException
, URISyntaxException
{
449 // Link to the test traces folder. We use a link so that we can safely
450 // delete the entire project when we are done.
451 IProject project
= getProjectResource();
452 String canonicalPath
= new File(TRACE_FOLDER_PARENT_PATH
).getCanonicalPath();
453 IFolder folder
= project
.getFolder(TRACE_FOLDER_PARENT_NAME
);
454 folder
.createLink(new Path(canonicalPath
), IResource
.REPLACE
, null);
455 IFile file
= folder
.getFile(ARCHIVE_FILE_NAME
);
456 return createArchive(file
);
460 * Create the empty archive from an empty folder
462 private String
createEmptyArchive() throws CoreException
, URISyntaxException
{
463 return createArchive(createEmptyDirectory());
466 private IFolder
createEmptyDirectory() throws CoreException
{
467 IProject project
= getProjectResource();
468 IFolder folder
= project
.getFolder(EMPTY_ARCHIVE_FOLDER
);
469 folder
.create(true, true, null);
473 private static void createEmptyFile(IFolder folder
) throws CoreException
{
475 IFile file
= folder
.getFile(EMPTY_FILE_NAME
);
476 file
.create(new ByteArrayInputStream(new byte[0]), true, null);
480 * Create a temporary archive from the specified resource.
482 private static String
createArchive(IResource sourceResource
) throws URISyntaxException
{
483 IPath exportedPath
= sourceResource
.getFullPath();
485 SWTBotTreeItem traceFilesProject
= SWTBotUtils
.selectProject(fBot
, TRACE_PROJECT_NAME
);
486 traceFilesProject
.contextMenu("Export...").click();
488 fBot
.waitUntil(Conditions
.shellIsActive("Export"));
489 SWTBotShell activeShell
= fBot
.activeShell();
490 SWTBotTree exportWizardsTree
= fBot
.tree();
491 SWTBotTreeItem treeItem
= SWTBotUtils
.getTreeItem(fBot
, exportWizardsTree
, "General", "Archive File");
493 fBot
.button("Next >").click();
494 fBot
.button("&Deselect All").click();
496 if (sourceResource
instanceof IFile
) {
497 String
[] folderPath
= exportedPath
.removeLastSegments(1).segments();
498 String fileName
= exportedPath
.lastSegment();
499 selectFile(fileName
, folderPath
);
501 selectFolder(exportedPath
.segments());
504 String workspacePath
= URIUtil
.toFile(URIUtil
.fromString(System
.getProperty("osgi.instance.area"))).getAbsolutePath();
505 final String archiveDestinationPath
= workspacePath
+ File
.separator
+ TRACE_PROJECT_NAME
+ File
.separator
+ GENERATED_ARCHIVE_NAME
;
506 fBot
.comboBox().setText(archiveDestinationPath
);
507 fBot
.button("&Finish").click();
508 fBot
.waitUntil(Conditions
.shellCloses(activeShell
));
509 return archiveDestinationPath
;
512 private void testViews(TmfEventsEditor editor
) {
513 testHistogramView(getViewPart("Histogram"), editor
);
514 testPropertyView(getViewPart("Properties"));
515 testStatisticsView(getViewPart("Statistics"));
518 private static void openImportWizard() {
519 fWizard
= new ImportTraceWizard();
521 UIThreadRunnable
.asyncExec(new VoidResult() {
524 final IWorkbench workbench
= PlatformUI
.getWorkbench();
525 // Fire the Import Trace Wizard
526 if (workbench
!= null) {
527 final IWorkbenchWindow activeWorkbenchWindow
= workbench
.getActiveWorkbenchWindow();
528 Shell shell
= activeWorkbenchWindow
.getShell();
529 assertNotNull(shell
);
530 ((ImportTraceWizard
) fWizard
).init(PlatformUI
.getWorkbench(), StructuredSelection
.EMPTY
);
531 WizardDialog dialog
= new WizardDialog(shell
, fWizard
);
537 fBot
.waitUntil(ConditionHelpers
.isWizardReady(fWizard
));
540 private static void selectImportFromDirectory(String directoryPath
) {
541 SWTBotRadio button
= fBot
.radio("Select roo&t directory:");
544 SWTBotCombo sourceCombo
= fBot
.comboBox();
545 File traceFolderParent
= new File(directoryPath
);
546 sourceCombo
.setText(traceFolderParent
.getAbsolutePath());
548 SWTBotText text
= fBot
.text();
552 private static void selectImportFromArchive(String archivePath
) {
553 SWTBotRadio button
= fBot
.radio("Select &archive file:");
556 SWTBotCombo sourceCombo
= fBot
.comboBox(1);
558 sourceCombo
.setText(new File(archivePath
).getAbsolutePath());
560 SWTBotText text
= fBot
.text();
564 private static void selectFolder(String
... treePath
) {
565 selectFolder(true, treePath
);
568 private static void selectFolder(boolean check
, String
... treePath
) {
569 SWTBotTree tree
= fBot
.tree();
570 fBot
.waitUntil(Conditions
.widgetIsEnabled(tree
));
571 SWTBotTreeItem folderNode
= SWTBotUtils
.getTreeItem(fBot
, tree
, treePath
);
579 private static void selectFile(String fileName
, String
... folderTreePath
) {
580 selectFolder(false, folderTreePath
);
582 SWTBotTable fileTable
= fBot
.table();
583 fBot
.waitUntil(Conditions
.widgetIsEnabled(fileTable
));
584 fBot
.waitUntil(ConditionHelpers
.isTableItemAvailable(fileName
, fileTable
));
585 SWTBotTableItem tableItem
= fileTable
.getTableItem(fileName
);
589 private static void setOptions(int optionFlags
, String traceTypeName
) {
590 SWTBotCheckBox checkBox
= fBot
.checkBox(Messages
.ImportTraceWizard_CreateLinksInWorkspace
);
591 if (checkBox
.isEnabled()) {
592 if ((optionFlags
& ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
) != 0) {
599 checkBox
= fBot
.checkBox(Messages
.ImportTraceWizard_PreserveFolderStructure
);
600 if ((optionFlags
& ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
) != 0) {
606 checkBox
= fBot
.checkBox(Messages
.ImportTraceWizard_ImportUnrecognized
);
607 if ((optionFlags
& ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
) != 0) {
613 checkBox
= fBot
.checkBox(Messages
.ImportTraceWizard_OverwriteExistingTrace
);
614 if ((optionFlags
& ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
) != 0) {
620 SWTBotCombo comboBox
= fBot
.comboBoxWithLabel(Messages
.ImportTraceWizard_TraceType
);
621 if (traceTypeName
!= null && !traceTypeName
.isEmpty()) {
622 comboBox
.setSelection(traceTypeName
);
624 comboBox
.setSelection(ImportTraceWizardPage
.TRACE_TYPE_AUTO_DETECT
);
628 private void checkOptions(int optionFlags
, String expectedSourceLocation
, IPath expectedElementPath
) throws CoreException
{
629 IProject project
= getProjectResource();
630 assertTrue(project
.exists());
631 TmfProjectElement tmfProject
= TmfProjectRegistry
.getProject(project
, true);
632 assertNotNull(tmfProject
);
633 TmfTraceFolder tracesFolder
= tmfProject
.getTracesFolder();
634 assertNotNull(tracesFolder
);
635 List
<TmfTraceElement
> traces
= tracesFolder
.getTraces();
636 assertFalse(traces
.isEmpty());
637 Collections
.sort(traces
, new Comparator
<TmfTraceElement
>() {
639 public int compare(TmfTraceElement arg0
, TmfTraceElement arg1
) {
640 return arg0
.getElementPath().compareTo(arg1
.getElementPath());
644 TmfTraceElement tmfTraceElement
= traces
.get(0);
645 IResource traceResource
= tmfTraceElement
.getResource();
647 assertEquals((optionFlags
& ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
) != 0, traceResource
.isLinked());
649 // i.e. /Tracing/Traces
650 IPath expectedPath
= Path
.ROOT
.append(new Path(TRACE_PROJECT_NAME
)).append(TmfTracesFolder
.TRACES_FOLDER_NAME
).append(expectedElementPath
);
651 assertEquals(expectedPath
, traceResource
.getFullPath());
653 String sourceLocation
= traceResource
.getPersistentProperty(TmfCommonConstants
.SOURCE_LOCATION
);
654 assertNotNull(sourceLocation
);
655 assertEquals(expectedSourceLocation
, sourceLocation
);
659 protected String
getProjectName() {
660 return TRACE_PROJECT_NAME
;
663 private IProject
getProjectResource() {
664 return ResourcesPlugin
.getWorkspace().getRoot().getProject(getProjectName());