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
;
22 import java
.io
.IOException
;
23 import java
.net
.URISyntaxException
;
24 import java
.util
.Collections
;
25 import java
.util
.Comparator
;
26 import java
.util
.List
;
28 import org
.eclipse
.core
.resources
.IFile
;
29 import org
.eclipse
.core
.resources
.IFolder
;
30 import org
.eclipse
.core
.resources
.IProject
;
31 import org
.eclipse
.core
.resources
.IResource
;
32 import org
.eclipse
.core
.resources
.ResourcesPlugin
;
33 import org
.eclipse
.core
.runtime
.CoreException
;
34 import org
.eclipse
.core
.runtime
.IPath
;
35 import org
.eclipse
.core
.runtime
.Path
;
36 import org
.eclipse
.core
.runtime
.URIUtil
;
37 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
38 import org
.eclipse
.jface
.wizard
.WizardDialog
;
39 import org
.eclipse
.swt
.widgets
.Shell
;
40 import org
.eclipse
.swtbot
.swt
.finder
.finders
.UIThreadRunnable
;
41 import org
.eclipse
.swtbot
.swt
.finder
.junit
.SWTBotJunit4ClassRunner
;
42 import org
.eclipse
.swtbot
.swt
.finder
.results
.VoidResult
;
43 import org
.eclipse
.swtbot
.swt
.finder
.waits
.Conditions
;
44 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotCheckBox
;
45 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotCombo
;
46 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotRadio
;
47 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotShell
;
48 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTable
;
49 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTableItem
;
50 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotText
;
51 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTree
;
52 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTreeItem
;
53 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
.ImportTraceWizard
;
54 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
.ImportTraceWizardPage
;
55 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
.Messages
;
56 import org
.eclipse
.tracecompass
.tmf
.core
.TmfCommonConstants
;
57 import org
.eclipse
.tracecompass
.tmf
.ui
.editors
.TmfEventsEditor
;
58 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfProjectElement
;
59 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfProjectRegistry
;
60 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfTraceElement
;
61 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfTraceFolder
;
62 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfTracesFolder
;
63 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.ConditionHelpers
;
64 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.SWTBotUtils
;
65 import org
.eclipse
.ui
.IWorkbench
;
66 import org
.eclipse
.ui
.IWorkbenchWindow
;
67 import org
.eclipse
.ui
.PlatformUI
;
68 import org
.junit
.Test
;
69 import org
.junit
.runner
.RunWith
;
72 * SWTBot Smoke test using ImportTraceWizard.
74 * @author Bernd Hufmann
76 @RunWith(SWTBotJunit4ClassRunner
.class)
77 public class StandardImportAndReadSmokeTest
extends AbstractImportAndReadSmokeTest
{
79 private static final String TRACE_FOLDER_PARENT_PATH
= fTrace
.getPath() + File
.separator
+ ".." + File
.separator
+ ".." + File
.separator
;
80 private static final String ARCHIVE_FILE_NAME
= "synctraces.tar.gz";
81 private static final String EMPTY_ARCHIVE_FOLDER
= "emptyArchiveFolder";
82 private static final String TRACE_ARCHIVE_PATH
= TRACE_FOLDER_PARENT_PATH
+ ARCHIVE_FILE_NAME
;
83 private static final String TRACE_FOLDER_PARENT_NAME
= "traces";
84 private static final String TRACE_PROJECT_NAME
= "Tracing";
86 private static final String ARCHIVE_ROOT_ELEMENT_NAME
= "/";
87 private static final String GENERATED_ARCHIVE_NAME
= "testtraces.zip";
88 private static final String URI_SEPARATOR
= "/";
89 private static final String URI_FILE_SCHEME
= "file:";
90 private static final String URI_JAR_FILE_SCHEME
= "jar:file:";
91 private static final boolean IS_WIN32
= System
.getProperty("os.name").startsWith("Windows"); //$NON-NLS-1$//$NON-NLS-2$
92 private static final String URI_DEVICE_SEPARATOR
= IS_WIN32 ? URI_SEPARATOR
: "";
95 * Test import from directory
101 public void testImportFromDirectory() throws Exception
{
102 testImport(0, false, false);
106 * Test import from directory, create links
112 public void testImportFromDirectoryLinks() throws Exception
{
113 testImport(ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
, false, false);
117 * Test import from directory, preserve folder structure
123 public void testImportFromDirectoryPreserveFolder() throws Exception
{
124 testImport(ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
, false, false);
128 * Test import from directory, create links, preserve folder structure
134 public void testImportFromDirectoryLinksPreserveFolder() throws Exception
{
135 int options
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
136 testImport(options
, false, false);
140 * Test import from directory, overwrite all
146 public void testImportFromDirectoryOverwrite() throws Exception
{
147 testImport(0, false, false);
148 testImport(ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
, false, false);
152 * Test import from archive
158 public void testImportFromArchive() throws Exception
{
159 testImport(ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
, true, true);
163 * Test import from directory, preserve folder structure
164 * @throws Exception on error
167 public void testImportFromArchivePreserveFolder() throws Exception
{
168 testImport(ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
, false, true);
172 * Test import from directory, overwrite all
178 public void testImportFromArchiveOverwrite() throws Exception
{
179 testImport(0, false, true);
180 testImport(ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
, false, true);
184 * Test import from directory containing archives
190 public void testExtractArchivesFromDirectory() throws Exception
{
191 testImportAndExtractArchives(ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
, false);
195 * Test import from directory containing archives, create links
196 * @throws Exception on error
199 public void testExtractArchivesFromDirectoryLinks() throws Exception
{
200 testImportAndExtractArchives(ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
, false);
204 * Test import from directory containing archives, create links, preserve folder structure
205 * @throws Exception on error
208 public void testExtractArchivesFromDirectoryLinksPreserveStruture() throws Exception
{
209 testImportAndExtractArchives(ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
, false);
213 * Test import from archive containing archives
219 public void testExtractArchivesFromArchive() throws Exception
{
220 testImportAndExtractArchives(ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
, true);
224 * Test import from archive containing archives, preserve folder structure
230 public void testExtractArchivesFromArchivePreserveFolder() throws Exception
{
231 testImportAndExtractArchives(ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
, true);
235 * Test import from an empty archive. This should not import anything.
241 public void testEmptyArchive() throws Exception
{
243 String testArchivePath
= createEmptyArchive();
246 selectImportFromArchive(testArchivePath
);
247 selectFolder(ARCHIVE_ROOT_ELEMENT_NAME
);
248 setOptions(0, ImportTraceWizardPage
.TRACE_TYPE_AUTO_DETECT
);
253 SWTBotUtils
.deleteProject(getProjectName(), fBot
);
257 * Test import from an empty directory. This should not import anything.
263 public void testEmptyDirectory() throws Exception
{
265 String testDirectoryPath
= createEmptyDirectory().getLocation().toOSString();
268 selectImportFromDirectory(testDirectoryPath
);
269 selectFolder(EMPTY_ARCHIVE_FOLDER
);
270 setOptions(0, ImportTraceWizardPage
.TRACE_TYPE_AUTO_DETECT
);
275 SWTBotUtils
.deleteProject(getProjectName(), fBot
);
279 * Test import from a directory containing an empty archive. This should not import anything.
285 public void testDirectoryWithEmptyArchive() throws Exception
{
287 createEmptyArchive();
290 selectImportFromDirectory(getProjectResource().getLocation().toOSString());
291 selectFile(GENERATED_ARCHIVE_NAME
, getProjectName());
292 setOptions(0, ImportTraceWizardPage
.TRACE_TYPE_AUTO_DETECT
);
297 SWTBotUtils
.deleteProject(getProjectName(), fBot
);
301 * Test import from a nested empty archive. This should not import anything.
307 public void testNestedEmptyArchive() throws Exception
{
309 IProject project
= getProjectResource();
311 // Create the empty archive from an empty folder
312 String testArchivePath
= createEmptyArchive();
314 // Rename archive so that we can create a new one with the same name
315 project
.refreshLocal(IResource
.DEPTH_ONE
, null);
316 IFile
[] files
= project
.getWorkspace().getRoot().findFilesForLocationURI(new File(testArchivePath
).toURI());
317 IFile archiveFile
= files
[0];
318 String newEmptyArchiveName
= "nested" + archiveFile
.getName();
319 IPath dest
= archiveFile
.getFullPath().removeLastSegments(1).append(newEmptyArchiveName
);
320 archiveFile
.move(dest
, true, null);
321 IFile renamedArchiveFile
= archiveFile
.getWorkspace().getRoot().getFile(dest
);
323 createArchive(renamedArchiveFile
);
326 selectImportFromArchive(testArchivePath
);
327 selectFolder(ARCHIVE_ROOT_ELEMENT_NAME
);
328 setOptions(0, ImportTraceWizardPage
.TRACE_TYPE_AUTO_DETECT
);
333 SWTBotUtils
.deleteProject(getProjectName(), fBot
);
336 private void assertNoTraces() {
337 TmfProjectElement tmfProject
= TmfProjectRegistry
.getProject(getProjectResource(), true);
338 assertNotNull(tmfProject
);
339 TmfTraceFolder tracesFolder
= tmfProject
.getTracesFolder();
340 assertNotNull(tracesFolder
);
341 List
<TmfTraceElement
> traces
= tracesFolder
.getTraces();
342 assertTrue(traces
.isEmpty());
345 private void testImport(int options
, boolean testViews
, boolean fromArchive
) throws Exception
{
347 String expectedSourceLocation
= null;
350 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
;
351 selectImportFromArchive(TRACE_ARCHIVE_PATH
);
352 selectFolder(ARCHIVE_ROOT_ELEMENT_NAME
);
353 SWTBotCheckBox checkBox
= fBot
.checkBox(Messages
.ImportTraceWizard_CreateLinksInWorkspace
);
354 assertFalse(checkBox
.isEnabled());
356 String sourcePath
= TRACE_FOLDER_PARENT_PATH
+ File
.separator
+ TRACE_FOLDER
+ File
.separator
+ TRACE_NAME
;
357 expectedSourceLocation
= URI_FILE_SCHEME
+ URI_DEVICE_SEPARATOR
+ new Path(new File(sourcePath
).getCanonicalPath()) + URI_SEPARATOR
;
358 selectImportFromDirectory(TRACE_FOLDER_PARENT_PATH
);
359 selectFolder(new String
[] {TRACE_FOLDER_PARENT_NAME
, TRACE_FOLDER
});
362 setOptions(options
, ImportTraceWizardPage
.TRACE_TYPE_AUTO_DETECT
);
365 IPath expectedElementPath
= new Path(TRACE_NAME
);
366 if ((options
& ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
) != 0) {
367 expectedElementPath
= new Path(TRACE_FOLDER
).append(expectedElementPath
);
370 checkOptions(options
, expectedSourceLocation
, expectedElementPath
);
371 TmfEventsEditor tmfEd
= SWTBotUtils
.openEditor(fBot
, getProjectName(), expectedElementPath
);
376 fBot
.closeAllEditors();
378 SWTBotUtils
.deleteProject(getProjectName(), fBot
);
381 private void testImportAndExtractArchives(int options
, boolean fromArchive
) throws Exception
{
384 String expectedSourceLocation
;
385 IPath expectedElementPath
;
387 String testArchivePath
= createNestedArchive();
389 selectImportFromArchive(testArchivePath
);
390 selectFile(ARCHIVE_FILE_NAME
, ARCHIVE_ROOT_ELEMENT_NAME
, TRACE_PROJECT_NAME
, TRACE_FOLDER_PARENT_NAME
);
392 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
393 + URI_SEPARATOR
+ TRACE_FOLDER
+ URI_SEPARATOR
+ TRACE_NAME
+ URI_SEPARATOR
;
394 expectedElementPath
= new Path(TRACE_PROJECT_NAME
).append(TRACE_FOLDER_PARENT_NAME
).append(ARCHIVE_FILE_NAME
).append(TRACE_FOLDER
).append(TRACE_NAME
);
397 selectImportFromDirectory(TRACE_FOLDER_PARENT_PATH
);
398 selectFile(ARCHIVE_FILE_NAME
, TRACE_FOLDER_PARENT_NAME
);
399 expectedElementPath
= new Path(ARCHIVE_FILE_NAME
).append(TRACE_FOLDER
).append(TRACE_NAME
);
400 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
;
403 if ((options
& ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
) == 0) {
404 expectedElementPath
= new Path(TRACE_NAME
);
407 setOptions(options
, ImportTraceWizardPage
.TRACE_TYPE_AUTO_DETECT
);
409 // Archives should never be imported as links
410 int expectedOptions
= options
& ~ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
411 checkOptions(expectedOptions
, expectedSourceLocation
, expectedElementPath
);
413 TmfEventsEditor editor
= SWTBotUtils
.openEditor(fBot
, TRACE_PROJECT_NAME
, expectedElementPath
);
416 SWTBotUtils
.deleteProject(getProjectName(), fBot
);
420 * Create a temporary archive containing a nested archive. For example,
421 * testtraces.zip/synctraces.tar.gz can be used to test a nested archive.
423 private String
createNestedArchive() throws IOException
, CoreException
, URISyntaxException
{
424 // Link to the test traces folder. We use a link so that we can safely
425 // delete the entire project when we are done.
426 IProject project
= getProjectResource();
427 String canonicalPath
= new File(TRACE_FOLDER_PARENT_PATH
).getCanonicalPath();
428 IFolder folder
= project
.getFolder(TRACE_FOLDER_PARENT_NAME
);
429 folder
.createLink(new Path(canonicalPath
), IResource
.REPLACE
, null);
430 IFile file
= folder
.getFile(ARCHIVE_FILE_NAME
);
431 return createArchive(file
);
435 * Create the empty archive from an empty folder
437 private String
createEmptyArchive() throws CoreException
, URISyntaxException
{
438 return createArchive(createEmptyDirectory());
441 private IFolder
createEmptyDirectory() throws CoreException
{
442 IProject project
= getProjectResource();
443 IFolder folder
= project
.getFolder(EMPTY_ARCHIVE_FOLDER
);
444 folder
.create(true, true, null);
449 * Create a temporary archive from the specified resource.
451 private static String
createArchive(IResource sourceResource
) throws URISyntaxException
{
452 IPath exportedPath
= sourceResource
.getFullPath();
454 SWTBotTreeItem traceFilesProject
= SWTBotUtils
.selectProject(fBot
, TRACE_PROJECT_NAME
);
455 traceFilesProject
.contextMenu("Export...").click();
457 fBot
.waitUntil(Conditions
.shellIsActive("Export"));
458 SWTBotShell activeShell
= fBot
.activeShell();
459 SWTBotTree exportWizardsTree
= fBot
.tree();
460 SWTBotTreeItem treeItem
= SWTBotUtils
.getTreeItem(fBot
, exportWizardsTree
, "General", "Archive File");
462 fBot
.button("Next >").click();
463 fBot
.button("&Deselect All").click();
465 if (sourceResource
instanceof IFile
) {
466 String
[] folderPath
= exportedPath
.removeLastSegments(1).segments();
467 String fileName
= exportedPath
.lastSegment();
468 selectFile(fileName
, folderPath
);
470 selectFolder(exportedPath
.segments());
473 String workspacePath
= URIUtil
.toFile(URIUtil
.fromString(System
.getProperty("osgi.instance.area"))).getAbsolutePath();
474 final String archiveDestinationPath
= workspacePath
+ File
.separator
+ TRACE_PROJECT_NAME
+ File
.separator
+ GENERATED_ARCHIVE_NAME
;
475 fBot
.comboBox().setText(archiveDestinationPath
);
476 fBot
.button("&Finish").click();
477 fBot
.waitUntil(Conditions
.shellCloses(activeShell
));
478 return archiveDestinationPath
;
481 private void testViews(TmfEventsEditor editor
) {
482 testHistogramView(getViewPart("Histogram"), editor
);
483 testPropertyView(getViewPart("Properties"));
484 testStatisticsView(getViewPart("Statistics"));
487 private static void openImportWizard() {
488 fWizard
= new ImportTraceWizard();
490 UIThreadRunnable
.asyncExec(new VoidResult() {
493 final IWorkbench workbench
= PlatformUI
.getWorkbench();
494 // Fire the Import Trace Wizard
495 if (workbench
!= null) {
496 final IWorkbenchWindow activeWorkbenchWindow
= workbench
.getActiveWorkbenchWindow();
497 Shell shell
= activeWorkbenchWindow
.getShell();
498 assertNotNull(shell
);
499 ((ImportTraceWizard
) fWizard
).init(PlatformUI
.getWorkbench(), StructuredSelection
.EMPTY
);
500 WizardDialog dialog
= new WizardDialog(shell
, fWizard
);
506 fBot
.waitUntil(ConditionHelpers
.isWizardReady(fWizard
));
509 private static void selectImportFromDirectory(String directoryPath
) {
510 SWTBotRadio button
= fBot
.radio("Select roo&t directory:");
513 SWTBotCombo sourceCombo
= fBot
.comboBox();
514 File traceFolderParent
= new File(directoryPath
);
515 sourceCombo
.setText(traceFolderParent
.getAbsolutePath());
517 SWTBotText text
= fBot
.text();
521 private static void selectImportFromArchive(String archivePath
) {
522 SWTBotRadio button
= fBot
.radio("Select &archive file:");
525 SWTBotCombo sourceCombo
= fBot
.comboBox(1);
527 sourceCombo
.setText(new File(archivePath
).getAbsolutePath());
529 SWTBotText text
= fBot
.text();
533 private static void selectFolder(String
... treePath
) {
534 selectFolder(true, treePath
);
537 private static void selectFolder(boolean check
, String
... treePath
) {
538 SWTBotTree tree
= fBot
.tree();
539 fBot
.waitUntil(Conditions
.widgetIsEnabled(tree
));
540 SWTBotTreeItem folderNode
= SWTBotUtils
.getTreeItem(fBot
, tree
, treePath
);
548 private static void selectFile(String fileName
, String
... folderTreePath
) {
549 selectFolder(false, folderTreePath
);
551 SWTBotTable fileTable
= fBot
.table();
552 fBot
.waitUntil(Conditions
.widgetIsEnabled(fileTable
));
553 fBot
.waitUntil(ConditionHelpers
.isTableItemAvailable(fileName
, fileTable
));
554 SWTBotTableItem tableItem
= fileTable
.getTableItem(fileName
);
558 private static void setOptions(int optionFlags
, String traceTypeName
) {
559 SWTBotCheckBox checkBox
= fBot
.checkBox(Messages
.ImportTraceWizard_CreateLinksInWorkspace
);
560 if (checkBox
.isEnabled()) {
561 if ((optionFlags
& ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
) != 0) {
568 checkBox
= fBot
.checkBox(Messages
.ImportTraceWizard_PreserveFolderStructure
);
569 if ((optionFlags
& ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
) != 0) {
575 checkBox
= fBot
.checkBox(Messages
.ImportTraceWizard_ImportUnrecognized
);
576 if ((optionFlags
& ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
) != 0) {
582 checkBox
= fBot
.checkBox(Messages
.ImportTraceWizard_OverwriteExistingTrace
);
583 if ((optionFlags
& ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
) != 0) {
589 SWTBotCombo comboBox
= fBot
.comboBoxWithLabel(Messages
.ImportTraceWizard_TraceType
);
590 if (traceTypeName
!= null && !traceTypeName
.isEmpty()) {
591 comboBox
.setSelection(traceTypeName
);
593 comboBox
.setSelection(ImportTraceWizardPage
.TRACE_TYPE_AUTO_DETECT
);
597 private void checkOptions(int optionFlags
, String expectedSourceLocation
, IPath expectedElementPath
) throws CoreException
{
598 IProject project
= getProjectResource();
599 assertTrue(project
.exists());
600 TmfProjectElement tmfProject
= TmfProjectRegistry
.getProject(project
, true);
601 assertNotNull(tmfProject
);
602 TmfTraceFolder tracesFolder
= tmfProject
.getTracesFolder();
603 assertNotNull(tracesFolder
);
604 List
<TmfTraceElement
> traces
= tracesFolder
.getTraces();
605 assertFalse(traces
.isEmpty());
606 Collections
.sort(traces
, new Comparator
<TmfTraceElement
>() {
608 public int compare(TmfTraceElement arg0
, TmfTraceElement arg1
) {
609 return arg0
.getElementPath().compareTo(arg1
.getElementPath());
613 TmfTraceElement tmfTraceElement
= traces
.get(0);
614 IResource traceResource
= tmfTraceElement
.getResource();
616 assertEquals((optionFlags
& ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
) != 0, traceResource
.isLinked());
618 // i.e. /Tracing/Traces
619 IPath expectedPath
= Path
.ROOT
.append(new Path(TRACE_PROJECT_NAME
)).append(TmfTracesFolder
.TRACES_FOLDER_NAME
).append(expectedElementPath
);
620 assertEquals(expectedPath
, traceResource
.getFullPath());
622 String sourceLocation
= traceResource
.getPersistentProperty(TmfCommonConstants
.SOURCE_LOCATION
);
623 assertNotNull(sourceLocation
);
624 assertEquals(expectedSourceLocation
, sourceLocation
);
628 protected String
getProjectName() {
629 return TRACE_PROJECT_NAME
;
632 private IProject
getProjectResource() {
633 return ResourcesPlugin
.getWorkspace().getRoot().getProject(getProjectName());