1 /******************************************************************************
2 * Copyright (c) 2016, 2017 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
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.integration
.swtbot
.tests
.projectexplorer
;
12 import static org
.junit
.Assert
.assertEquals
;
13 import static org
.junit
.Assert
.assertNotEquals
;
16 import java
.io
.IOException
;
17 import java
.util
.List
;
19 import java
.util
.function
.Supplier
;
21 import org
.apache
.log4j
.Logger
;
22 import org
.apache
.log4j
.varia
.NullAppender
;
23 import org
.eclipse
.core
.runtime
.IPath
;
24 import org
.eclipse
.core
.runtime
.Path
;
25 import org
.eclipse
.jdt
.annotation
.NonNull
;
26 import org
.eclipse
.swtbot
.eclipse
.finder
.SWTWorkbenchBot
;
27 import org
.eclipse
.swtbot
.eclipse
.finder
.widgets
.SWTBotEditor
;
28 import org
.eclipse
.swtbot
.eclipse
.finder
.widgets
.SWTBotView
;
29 import org
.eclipse
.swtbot
.swt
.finder
.SWTBot
;
30 import org
.eclipse
.swtbot
.swt
.finder
.junit
.SWTBotJunit4ClassRunner
;
31 import org
.eclipse
.swtbot
.swt
.finder
.utils
.SWTBotPreferences
;
32 import org
.eclipse
.swtbot
.swt
.finder
.waits
.Conditions
;
33 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotButton
;
34 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotShell
;
35 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTree
;
36 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTreeItem
;
37 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
.ImportConfirmation
;
38 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
.ImportTraceWizardPage
;
39 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTxtTraceDefinition
;
40 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomXmlTraceDefinition
;
41 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
42 import org
.eclipse
.tracecompass
.tmf
.ctf
.ui
.swtbot
.tests
.SWTBotImportWizardUtils
;
43 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.ConditionHelpers
;
44 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.SWTBotUtils
;
45 import org
.eclipse
.tracecompass
.tmf
.ui
.tests
.shared
.WaitUtils
;
46 import org
.eclipse
.ui
.IPageLayout
;
47 import org
.junit
.After
;
48 import org
.junit
.AfterClass
;
49 import org
.junit
.BeforeClass
;
50 import org
.junit
.FixMethodOrder
;
51 import org
.junit
.Test
;
52 import org
.junit
.runner
.RunWith
;
53 import org
.junit
.runners
.MethodSorters
;
55 import com
.google
.common
.collect
.ImmutableList
;
56 import com
.google
.common
.collect
.ImmutableSet
;
57 import com
.google
.common
.collect
.Lists
;
60 * SWTBot test for testing Project Explorer trace folders (context-menu,
63 @RunWith(SWTBotJunit4ClassRunner
.class)
64 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
65 @SuppressWarnings({"restriction", "javadoc"})
66 public class ProjectExplorerTracesFolderTest
{
68 private static final class ImportConfirmationSupplier
implements Supplier
<ImportConfirmation
> {
69 List
<ImportConfirmation
> fConfirmations
= Lists
.newArrayList(ImportConfirmation
.CONTINUE
);
71 public ImportConfirmationSupplier(ImportConfirmation
... confirmations
) {
72 fConfirmations
= Lists
.newArrayList(confirmations
);
76 public ImportConfirmation
get() {
77 return fConfirmations
.isEmpty() ?
null : fConfirmations
.remove(0);
81 private static final String PROP_LAST_MODIFIED_PROPERTY
= "last modified";
82 private static final String TEXT_EDITOR_ID
= "org.eclipse.ui.DefaultTextEditor";
84 private static final String GENERIC_CTF_TRACE_TYPE
= "Common Trace Format : Generic CTF Trace";
85 private static final String LTTNG_KERNEL_TRACE_TYPE
= "Common Trace Format : Linux Kernel Trace";
86 private static final String LTTNG_UST_TRACE_TYPE
= "Common Trace Format : LTTng UST Trace";
87 private static final String CUSTOM_TEXT_TRACE_TYPE
= "Custom Text : TmfGeneric";
88 private static final String CUSTOM_XML_TRACE_TYPE
= "Custom XML : Custom XML Log";
90 private static final @NonNull TestTraceInfo CUSTOM_TEXT_LOG
= new TestTraceInfo("ExampleCustomTxt.log", CUSTOM_TEXT_TRACE_TYPE
, 10, "29:52.034");
91 private static final @NonNull TestTraceInfo CUSTOM_XML_LOG
= new TestTraceInfo("ExampleCustomXml.xml", CUSTOM_XML_TRACE_TYPE
, 6, "22:01:20");
92 private static final @NonNull TestTraceInfo LTTNG_KERNEL_TRACE
= new TestTraceInfo("kernel-overlap-testing", LTTNG_KERNEL_TRACE_TYPE
, 1000, "04:32.650 993 664");
93 private static final @NonNull TestTraceInfo SIMPLE_SERVER1_UST_TRACE
= new TestTraceInfo("simple_server-thread1", LTTNG_UST_TRACE_TYPE
, 1000, "04:32.650 993 664");
94 private static final @NonNull TestTraceInfo SIMPLE_SERVER2_UST_TRACE
= new TestTraceInfo("simple_server-thread2", LTTNG_UST_TRACE_TYPE
, 1000, "04:32.650 993 664");
95 private static final @NonNull TestTraceInfo UST_OVERLAP_TESTING_UST_TRACE
= new TestTraceInfo("ust-overlap-testing", LTTNG_UST_TRACE_TYPE
, 1000, "04:32.650 993 664");
97 private static final String CLASHES_DIR_NAME
= "z-clashes";
98 private static final @NonNull TestTraceInfo CLASHES_CUSTOM_TEXT_LOG
= new TestTraceInfo("ExampleCustomTxt.log", CLASHES_DIR_NAME
+ "/ExampleCustomTxt.log", CUSTOM_TEXT_TRACE_TYPE
, 11, "29:52.034");
99 private static final @NonNull TestTraceInfo CLASHES_CUSTOM_XML_LOG
= new TestTraceInfo("ExampleCustomXml.xml", CLASHES_DIR_NAME
+ "/ExampleCustomXml.xml", CUSTOM_XML_TRACE_TYPE
, 7, "22:01:20");
100 private static final @NonNull TestTraceInfo CLASHES_LTTNG_KERNEL_TRACE
= new TestTraceInfo("kernel-overlap-testing", CLASHES_DIR_NAME
+ "/kernel-overlap-testing", LTTNG_KERNEL_TRACE_TYPE
, 1001, "04:32.650 993 664");
101 private static final @NonNull TestTraceInfo CLASHES_SIMPLE_SERVER1_UST_TRACE
= new TestTraceInfo("simple_server-thread1", CLASHES_DIR_NAME
+ "/simple_server-thread1", LTTNG_UST_TRACE_TYPE
, 1001, "04:32.650 993 664");
102 private static final @NonNull TestTraceInfo CLASHES_SIMPLE_SERVER2_UST_TRACE
= new TestTraceInfo("simple_server-thread2", CLASHES_DIR_NAME
+ "/simple_server-thread2", LTTNG_UST_TRACE_TYPE
, 1001, "04:32.650 993 664");
103 private static final @NonNull TestTraceInfo CLASHES_UST_OVERLAP_TESTING_UST_TRACE
= new TestTraceInfo("ust-overlap-testing", CLASHES_DIR_NAME
+ "/ust-overlap-testing", LTTNG_UST_TRACE_TYPE
, 1001, "04:32.650 993 664");
106 private static final @NonNull TestTraceInfo LTTNG_KERNEL_TRACE_METADATA
= new TestTraceInfo(LTTNG_KERNEL_TRACE
.getTraceName(), LTTNG_KERNEL_TRACE
.getTraceName() + "/metadata", LTTNG_KERNEL_TRACE
.getTraceType(), LTTNG_KERNEL_TRACE
.getNbEvents(),
107 LTTNG_KERNEL_TRACE
.getFirstEventTimestamp());
108 private static final @NonNull TestTraceInfo UNRECOGNIZED_LOG
= new TestTraceInfo("unrecognized.log", "", 0, "");
109 private static final @NonNull TestTraceInfo CUSTOM_XML_LOG_AS_TEXT
= new TestTraceInfo("ExampleCustomXml.xml", CUSTOM_TEXT_TRACE_TYPE
, 0, "");
110 private static final @NonNull TestTraceInfo CLASHES_CUSTOM_XML_LOG_AS_TEXT
= new TestTraceInfo("ExampleCustomXml.xml", CLASHES_DIR_NAME
+ "/ExampleCustomXml.xml", CUSTOM_TEXT_TRACE_TYPE
, 0, "");
112 private static final TestTraceInfo
[] ALL_TRACEINFOS
= new TestTraceInfo
[] {
116 SIMPLE_SERVER1_UST_TRACE
,
117 SIMPLE_SERVER2_UST_TRACE
,
118 UST_OVERLAP_TESTING_UST_TRACE
,
120 CLASHES_CUSTOM_TEXT_LOG
,
121 CLASHES_CUSTOM_XML_LOG
,
122 CLASHES_LTTNG_KERNEL_TRACE
,
123 CLASHES_SIMPLE_SERVER1_UST_TRACE
,
124 CLASHES_SIMPLE_SERVER2_UST_TRACE
,
125 CLASHES_UST_OVERLAP_TESTING_UST_TRACE
128 private static final Set
<TestTraceInfo
> CLASHING_TRACEINFOS
= ImmutableSet
.of(
129 CLASHES_CUSTOM_TEXT_LOG
,
130 CLASHES_CUSTOM_XML_LOG
,
131 CLASHES_LTTNG_KERNEL_TRACE
,
132 CLASHES_SIMPLE_SERVER1_UST_TRACE
,
133 CLASHES_SIMPLE_SERVER2_UST_TRACE
,
134 CLASHES_UST_OVERLAP_TESTING_UST_TRACE
);
136 // All normal traces plus the unrecognized trace
137 private static final int NUM_UNIQUE_TRACES
= CLASHING_TRACEINFOS
.size() + 1;
140 private static final File TEST_TRACES_PATH
= new File(new Path(TmfTraceManager
.getTemporaryDirPath()).append("testtraces").toOSString());
141 private static final String DEFAULT_PROJECT_NAME
= "Tracing";
142 private static final String TRACE_PROJECT_NAME
= "test";
143 private static final String MANAGE_CUSTOM_PARSERS_SHELL_TITLE
= "Manage Custom Parsers";
145 private static SWTWorkbenchBot fBot
;
147 /** The Log4j logger instance. */
148 private static final Logger fLogger
= Logger
.getRootLogger();
150 private static String
getPath(String relativePath
) {
151 return new Path(TEST_TRACES_PATH
.getAbsolutePath()).append(relativePath
).toOSString();
157 * @throws IOException
160 public static void init() throws IOException
{
161 TestDirectoryStructureUtil
.generateTraceStructure(TEST_TRACES_PATH
);
163 SWTBotUtils
.initialize();
165 /* Set up for swtbot */
166 SWTBotPreferences
.TIMEOUT
= 20000; /* 20 second timeout */
167 SWTBotPreferences
.KEYBOARD_LAYOUT
= "EN_US";
168 fLogger
.removeAllAppenders();
169 fLogger
.addAppender(new NullAppender());
170 fBot
= new SWTWorkbenchBot();
172 SWTBotUtils
.closeView("Welcome", fBot
);
174 SWTBotUtils
.switchToTracingPerspective();
176 /* Finish waiting for eclipse to load */
177 WaitUtils
.waitForJobs();
178 SWTBotUtils
.createProject(TRACE_PROJECT_NAME
);
179 importCustomParsers();
183 * Test class tear down method.
186 public static void tearDown() {
187 SWTBotUtils
.deleteProject(TRACE_PROJECT_NAME
, fBot
);
188 SWTBotUtils
.deleteProject(DEFAULT_PROJECT_NAME
, fBot
);
189 fLogger
.removeAllAppenders();
193 * Test tear down method.
196 public void afterTest() {
197 SWTBotUtils
.closeSecondaryShells(fBot
);
200 private static void importCustomParsers() {
201 // FIXME: We can't use Manage Custom Parsers > Import because it uses a native dialog. We'll still check that they show up in the dialog
202 CustomTxtTraceDefinition
[] txtDefinitions
= CustomTxtTraceDefinition
.loadAll(getPath("customParsers/ExampleCustomTxtParser.xml"));
203 txtDefinitions
[0].save();
204 CustomXmlTraceDefinition
[] xmlDefinitions
= CustomXmlTraceDefinition
.loadAll(getPath("customParsers/ExampleCustomXmlParser.xml"));
205 xmlDefinitions
[0].save();
207 SWTBotTreeItem traceFolder
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
208 traceFolder
.contextMenu("Manage Custom Parsers...").click();
209 fBot
.waitUntil(Conditions
.shellIsActive(MANAGE_CUSTOM_PARSERS_SHELL_TITLE
));
210 SWTBotShell shell
= fBot
.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE
);
211 SWTBot shellBot
= shell
.bot();
213 // Make sure the custom text trace type is imported
214 shellBot
.list().select(CUSTOM_TEXT_LOG
.getTraceType());
216 // Make sure the custom xml trace type is imported
217 shellBot
.radio("XML").click();
218 shellBot
.list().select(CUSTOM_XML_LOG
.getTraceType());
219 shellBot
.button("Close").click();
220 shellBot
.waitUntil(Conditions
.shellCloses(shell
));
224 * Test that the expected context menu items are there
226 * Action : Trace Folder menu
228 * Procedure :Select the Traces folder and open its context menu
230 * Expected Results: Correct menu opens (Import, Refresh, etc)
233 public void test3_01ContextMenuPresence() {
234 SWTBotTreeItem traceItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
236 final List
<String
> EXPECTED_MENU_LABELS
= ImmutableList
.of(
238 "Open As Experiment...",
245 "Import Trace Package...",
246 "Fetch Remote Traces...",
248 "Export Trace Package...",
250 "Manage Custom Parsers...",
251 "Manage XML analyses...",
253 "Apply Time Offset...",
258 List
<String
> menuLabels
= traceItem
.contextMenu().menuItems();
259 for (int i
= 0; i
< menuLabels
.size(); i
++) {
260 assertEquals(EXPECTED_MENU_LABELS
.get(i
), menuLabels
.get(i
));
263 fBot
.closeAllEditors();
267 * Test that the trace import wizard appears
269 * Action : Trace Import Wizard
271 * Procedure : Select Import
273 * Expected Results: Trace Import Wizard appears
276 public void test3_02Import() {
277 SWTBotTreeItem traceItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
279 SWTBotShell shell
= openTraceFoldersImport(traceItem
);
280 shell
.bot().button("Cancel").click();
284 * Test that the trace import wizard can import a single custom text trace
286 * Action : Import single custom text trace (link to workspace)
289 * Procedure : 1) Browse to directory ${local}/traces/import/
290 * 2) Select trace ExampleCustomTxt.log
291 * 3) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning" and select "Create Links to workspace" and
295 * Expected Results: Imported trace appear in Traces Folder and the Trace Type Tmf Generic is set. Make sure trace can be opened
298 public void test3_03SingleCustomTextTrace() {
299 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
300 testSingleTrace(CUSTOM_TEXT_LOG
, optionFlags
);
305 * Action : Import Single custom XML trace (link to workspace)
309 * Procedure : redo 3.1-3.3 but this time select ExampleCustomXml.xml
312 * Expected Results: Imported trace appear in Traces Folder and the Trace
313 * Type "Custom XML log" is set. Make sure that trace can be opened
316 public void test3_04SingleCustomXmlTrace() {
317 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
318 testSingleTrace(CUSTOM_XML_LOG
, optionFlags
);
323 * Action : Import LTTng Kernel CTF trace (link to workspace)
327 * Procedure : redo 3.1-3.3 but this time select directory kernel-overlap-testing/
330 * Expected Results: Imported trace appear in Traces Folder and the Trace
331 * Type "LTTng Kernel" is set. Make sure that trace can be opened
334 public void test3_05SingleCtfTrace() {
335 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
336 testSingleTrace(LTTNG_KERNEL_TRACE
, optionFlags
);
341 * Action : Rename + copy import
345 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace"
346 * 2) When dialog box appear select Rename
349 * Expected Results: Traces are imported with new name that has a suffix (2)
350 * at the end. Make sure that imported traces are copied to the project.
353 public void test3_06RenameCopyImport() {
354 testRenameCopyImport(CUSTOM_TEXT_LOG
);
355 testRenameCopyImport(CUSTOM_XML_LOG
);
356 testRenameCopyImport(LTTNG_KERNEL_TRACE
);
359 private static void testRenameCopyImport(TestTraceInfo traceInfo
) {
360 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
;
361 importTrace(optionFlags
, ImportConfirmation
.RENAME
, traceInfo
.getTraceName());
362 String renamed
= toRenamedName(traceInfo
.getTraceName());
363 verifyTrace(traceInfo
, optionFlags
, renamed
);
368 * Action : Overwrite + copy import
372 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace"
373 * 2) When dialog box appear select Overwrite
376 * Expected Results: Existing traces are deleted and new traces are
377 * imported. Make sure that imported traces are copied to the project and
381 public void test3_07OverwriteCopyImport() {
382 testOverwriteCopyImport(CUSTOM_TEXT_LOG
);
383 testOverwriteCopyImport(CUSTOM_XML_LOG
);
384 testOverwriteCopyImport(LTTNG_KERNEL_TRACE
);
387 private static void testOverwriteCopyImport(TestTraceInfo traceInfo
) {
388 String traceName
= traceInfo
.getTraceName();
389 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
), traceName
);
390 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
391 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
;
392 importTrace(optionFlags
, ImportConfirmation
.OVERWRITE
, traceName
);
393 verifyTrace(traceInfo
, optionFlags
);
395 assertNotEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
404 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace"
405 * 2) When dialog box appear select Skip
408 * Expected Results: Make sure that no new trace is imported
411 public void test3_08SkipImport() {
412 testSkipImport(CUSTOM_TEXT_LOG
);
413 testSkipImport(CUSTOM_XML_LOG
);
414 testSkipImport(LTTNG_KERNEL_TRACE
);
417 private static void testSkipImport(TestTraceInfo traceInfo
) {
418 String traceName
= traceInfo
.getTraceName();
419 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
), traceName
);
420 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
421 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
;
422 importTrace(optionFlags
, ImportConfirmation
.SKIP
, traceName
);
423 verifyTrace(traceInfo
, optionFlags
);
425 assertEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
430 * Action : Default overwrite
434 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace" and select "Overwrite existing without warning"
437 * Expected Results: Make sure that no dialog box appears (for renaming,
438 * overwriting, skipping) and existing traces are overwritten). Make sure
439 * trace can be opened
442 public void test3_09OverwriteOptionImport() {
443 testOverwriteOptionImport(CUSTOM_TEXT_LOG
);
444 testOverwriteOptionImport(CUSTOM_XML_LOG
);
445 testOverwriteOptionImport(LTTNG_KERNEL_TRACE
);
448 private static void testOverwriteOptionImport(TestTraceInfo traceInfo
) {
449 String traceName
= traceInfo
.getTraceName();
450 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
), traceName
);
451 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
453 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
;
454 importTrace(optionFlags
, ImportConfirmation
.CONTINUE
, traceName
);
455 verifyTrace(traceInfo
, optionFlags
);
457 assertNotEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
462 * Action : Import unrecognized
466 * Procedure : 1) Open Import wizard (see 3.1-3.2)
467 * 2) Browse to directory ${local}/traces/import
468 * 3) Select trace unrecognized.log
469 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning" and select "Create Links to workspace" and
473 * Expected Results: unrecognized.log is imported with trace type unknown.
474 * The default text file icon is displayed. The trace, when opened, is
475 * displayed in the text editor.
478 public void test3_10ImportUnrecognized() {
479 String traceName
= UNRECOGNIZED_LOG
.getTraceName();
480 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
481 importTrace(optionFlags
, traceName
);
482 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
487 * Action : Import unrecognized (ignore)
491 * Procedure : 1) redo 3.10, however unselect "Import unrecognized traces"
494 * Expected Results: unrecognized.log is not imported
497 public void test3_11ImportUnrecognizedIgnore() {
498 String traceName
= UNRECOGNIZED_LOG
.getTraceName();
499 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
500 int numTraces
= tracesFolderItem
.getItems().length
;
502 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, tracesFolderItem
, traceName
);
503 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
505 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
506 importTrace(optionFlags
, traceName
);
507 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
509 assertEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
510 assertEquals(numTraces
, tracesFolderItem
.getItems().length
);
515 * Action : Import CTF trace by selection metadata file only
519 * Procedure : 1) Redo 3.5, However only select metadata file instead of directory trace
522 * Expected Results: Imported trace appear in Traces Folder and the Trace
523 * Type "LTTng Kernel" is set. Make sure that trace can be opened
526 public void test3_12ImportCtfWithMetadataSelection() {
527 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
528 testSingleTrace(LTTNG_KERNEL_TRACE_METADATA
, ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
);
533 * Action : Recursive import with auto-detection (Rename All)
537 * Procedure : 1) Open Import wizard (see 3.1-3.2)
538 * 2) Browse to directory ${local}/traces/import
539 * 3) select directory import
540 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
542 * 6) When dialog appears select "Rename All"
545 * Expected Results: All Traces are imported with respective trace type set.
546 * Traces with name clashes are imported with suffix (2). 1 trace
547 * (unrecognized.log) is imported with trace type unknown. Make sure that
548 * traces can be opened which have a trace type set. The unknown trace type
549 * should open with the text editor.
552 public void test3_13ImportRecursiveAutoRenameAll() {
553 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
555 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
556 importTrace(optionFlags
, ImportConfirmation
.RENAME_ALL
, "");
558 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
559 String traceName
= info
.getTraceName();
560 if (CLASHING_TRACEINFOS
.contains(info
)) {
561 traceName
= toRenamedName(traceName
);
563 verifyTrace(info
, optionFlags
, traceName
);
566 // Also check unrecognized file
567 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
572 * Action : Recursive import with auto-detection (Overwrite All)
576 * Procedure : 1) Open Import wizard (see 3.1-3.2)
577 * 2) Browse to directory ${local}/traces/import/
578 * 3) select directory import
579 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
581 * 6) When dialog appears select Overwrite All"
584 * Expected Results: All Traces are imported with respective trace type set.
585 * Traces with name clashes are overwritten . 1 trace (unrecognized.log) is
586 * imported with trace type unknown. Make sure that traces can be opened
587 * which have a trace type set. The unknown trace type should open with the
591 public void test3_14ImportRecursiveAutoOverwriteAll() {
592 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
594 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
595 importTrace(optionFlags
, ImportConfirmation
.OVERWRITE_ALL
, "");
597 for (TestTraceInfo info
: CLASHING_TRACEINFOS
) {
598 verifyTrace(info
, optionFlags
);
601 // All traces should have clashed/overwritten (plus the unrecognized trace)
602 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
603 assertEquals(NUM_UNIQUE_TRACES
, tracesFolderItem
.getItems().length
);
605 // Also check unrecognized file
606 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
611 * Action : Recursive import with auto-detection (Skip All)
615 * Procedure : 1) Open Import wizard (see 3.1-3.2)
616 * 2) Browse to directory ${local}/traces/import/
617 * 3) select directory import
618 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning" and select "Create Links to workspace" and uncheck "preserve folder structure"
620 * 6) When dialog appears select Skip All"
623 * Expected Results: All Traces are imported with respective trace type set. Traces with name
624 * clashes are not imported. 1 trace (unrecognized.log) is imported with
625 * trace type unknown. The unknown trace type should open with the text
629 public void test3_15ImportRecursiveAutoSkipAll() {
630 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
632 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
633 importTrace(optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
635 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
636 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
637 if (!CLASHING_TRACEINFOS
.contains(info
)) {
638 verifyTrace(info
, optionFlags
);
642 // All traces should have skipped (plus the unrecognized trace)
643 assertEquals(NUM_UNIQUE_TRACES
, tracesFolderItem
.getItems().length
);
645 // Also check unrecognized file
646 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
651 * Action : Recursive import with auto-detection (test rename, overwrite and
656 * Procedure : 1) Open Import wizard (see 3.1-3.2)
657 * 2) Browse to directory ${local}/traces/import/
658 * 3) select directory import
659 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
661 * 6) When dialog appears select "Rename"
662 * 7) When dialog appears select "Overwrite"
663 * 8) When dialog appears select "Skip"
666 * Expected Results: All Traces are imported with respective trace type set. Traces with name
667 * clashes are either renamed, overwritten or skipped as per dialog action.
668 * Make sure that traces can be opened which have trace type set. The
669 * unknown trace type should open with the text editor.
672 public void test3_16ImportRecursiveAutoRenameOverwriteSkip() {
673 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
675 Supplier
<ImportConfirmation
> confirmationSupplier
= new ImportConfirmationSupplier(
676 ImportConfirmation
.RENAME
, ImportConfirmation
.OVERWRITE
, ImportConfirmation
.SKIP
);
677 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
678 importTrace(optionFlags
, confirmationSupplier
, LTTNG_KERNEL_TRACE
.getTracePath(), CLASHES_LTTNG_KERNEL_TRACE
.getTracePath(), SIMPLE_SERVER1_UST_TRACE
.getTracePath(), CLASHES_SIMPLE_SERVER1_UST_TRACE
.getTracePath(),
679 SIMPLE_SERVER2_UST_TRACE
.getTracePath(), CLASHES_SIMPLE_SERVER2_UST_TRACE
.getTracePath(), UNRECOGNIZED_LOG
.getTracePath());
681 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
);
684 String renamed
= toRenamedName(CLASHES_LTTNG_KERNEL_TRACE
.getTraceName());
685 verifyTrace(CLASHES_LTTNG_KERNEL_TRACE
, optionFlags
, renamed
);
688 verifyTrace(CLASHES_SIMPLE_SERVER1_UST_TRACE
, optionFlags
);
691 verifyTrace(SIMPLE_SERVER2_UST_TRACE
, optionFlags
);
693 // Also check unrecognized file
694 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
699 * Action : Recursive import with specific trace type 1 (Skip All) skip)
703 * Procedure : 1) Open Import wizard
704 * 2) Browse to directory ${local}/traces/import/
705 * 3) Select directory import
706 * 4) Select trace type "Generic CTF Trace", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"and
708 * 6) When dialog appears select Skip All"
711 * Expected Results: After selecting trace type, verify that button "Import
712 * unrecognized traces" is disabled. 4 CTF traces are imported with trace
713 * type "Generic CTF Trace" . Make sure that these traces can be opened
716 public void test3_17ImportRecursiveSpecifyTraceTypeCTF() {
717 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
719 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
720 importTrace(GENERIC_CTF_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
722 final TestTraceInfo
[] CTF_TRACEINFOS
= new TestTraceInfo
[] {
724 SIMPLE_SERVER1_UST_TRACE
,
725 SIMPLE_SERVER2_UST_TRACE
,
726 UST_OVERLAP_TESTING_UST_TRACE
728 for (TestTraceInfo info
: CTF_TRACEINFOS
) {
729 verifyTrace(info
, optionFlags
, info
.getTraceName(), GENERIC_CTF_TRACE_TYPE
);
732 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
733 assertEquals(CTF_TRACEINFOS
.length
, tracesFolderItem
.getItems().length
);
738 * Action : Recursive import with specific trace type 2 (Skip All)
742 * Procedure : 1) Open Import wizard (see 3.1-3.2)
743 * 2) Browse to directory ${local}/traces/import/
744 * 3) Select directory import
745 * 4) Select trace type "LTTng Kernel Trace", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
747 * 6) When dialog appears select Skip All"
750 * Expected Results: After selecting trace type, verify that button "Import
751 * unrecognized traces" is disabled. One LTTng Kernel trace is imported with
752 * trace type "LTTng Kernel Trace". Make sure that this trace can be opened.
755 public void test3_18ImportRecursiveSpecifyTraceTypeKernel() {
756 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
758 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
759 importTrace(LTTNG_KERNEL_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
761 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
);
763 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
764 assertEquals(1, tracesFolderItem
.getItems().length
);
769 * Action : Recursive import with specific trace type 3 (Skip All)
773 * Procedure : 1) Open Import wizard
774 * 2) Browse to directory ${local}/traces/import/
775 * 3) Select directory import
776 * 4) Select trace type "LTTng UST Trace", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
778 * 6) When dialog appears select Skip All"
781 * Expected Results: After selecting trace type, verify that button "Import
782 * unrecognized traces" is disabled. 3 LTTng UST traces are imported with
783 * trace type "LTTng UST Trace". Make sure that these traces can be opened.
786 public void test3_19ImportRecursiveSpecifyTraceTypeUST() {
787 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
789 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
790 importTrace(LTTNG_UST_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
792 final TestTraceInfo
[] UST_TRACEINFOS
= new TestTraceInfo
[] {
793 SIMPLE_SERVER1_UST_TRACE
,
794 SIMPLE_SERVER2_UST_TRACE
,
795 UST_OVERLAP_TESTING_UST_TRACE
797 for (TestTraceInfo info
: UST_TRACEINFOS
) {
798 verifyTrace(info
, optionFlags
);
801 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
802 assertEquals(UST_TRACEINFOS
.length
, tracesFolderItem
.getItems().length
);
807 * Action : Recursive import with specific trace type 4 (Skip All)
811 * Procedure : 1) Open Import wizard (see 3.1-3.2)
812 * 2) Browse to directory ${local}/traces/import/
813 * 3) select directory import
814 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
816 * 6) When dialog appears select Skip All"
819 * Expected Results: All text files in directories are imported as trace and
820 * trace type "Tmf Generic" is set. Note that trace type validation only
821 * checks for file exists and that file is not a directory. Make sure that
822 * these traces can be opened. However traces with wrong trace type won't
823 * show any events in the table.
826 public void test3_20ImportRecursiveSpecifyTraceTypeCustomText() {
827 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
829 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
830 importTrace(CUSTOM_TEXT_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
831 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
);
833 final TestTraceInfo
[] TEXT_BASED_TRACEINFOS
= new TestTraceInfo
[] {
835 CUSTOM_XML_LOG_AS_TEXT
,
838 for (TestTraceInfo info
: TEXT_BASED_TRACEINFOS
) {
839 verifyTrace(info
, optionFlags
, info
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
842 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
843 assertEquals(TEXT_BASED_TRACEINFOS
.length
, tracesFolderItem
.getItems().length
);
847 * Action : Test the import wizard from workbench menu with project selected
850 * Procedure : 1) Select Project "Test" in Project Explorer view
851 * 2) Open import wizard from menu File > Import... > Tracing > Trace Import
852 * 3) Browse to directory ${local}/traces/import/
853 * 4) Select trace ExampleCustomTxt.log
854 * 5) Keep <Auto Detection>, select "Create Links to workspace" and
858 * Expected Results: Verify that trace is imported to "Test" project and can be opened.
861 public void test3_21ImportFromMenuProjectSelected() {
862 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
864 SWTBotUtils
.selectProject(fBot
, TRACE_PROJECT_NAME
);
865 SWTBotShell shell
= openWorkbenchMenuImport();
866 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
867 importTrace(shell
, null, null, optionFlags
, new ImportConfirmationSupplier(), CUSTOM_TEXT_LOG
.getTracePath());
868 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
);
872 * Action : Test the import wizard from workbench menu with no project selected
875 * Procedure : 1) Clear selection in Project Explorer view
876 * 2) Open import wizard from menu File > Import... > Tracing > Trace Import
877 * 3) Browse to directory ${local}/traces/import/
878 * 4) Select trace ExampleCustomTxt.log
879 * 5) Keep <Auto Detection>, select "Create Links to workspace" and
883 * Expected Results: Verify that trace is imported to default "Tracing" project and can be opened.
886 public void test3_22ImportFromMenuProjectNotSelected() {
887 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
889 SWTBotView projectExplorerBot
= fBot
.viewByTitle("Project Explorer");
890 projectExplorerBot
.show();
891 projectExplorerBot
.bot().waitUntil(Conditions
.widgetIsEnabled(projectExplorerBot
.bot().tree()));
892 projectExplorerBot
.bot().tree().unselect();
893 SWTBotShell shell
= openWorkbenchMenuImport();
894 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
895 importTrace(shell
, null, null, optionFlags
, new ImportConfirmationSupplier(), CUSTOM_TEXT_LOG
.getTracePath());
896 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
, CUSTOM_TEXT_LOG
.getTraceName(), CUSTOM_TEXT_LOG
.getTraceType(), DEFAULT_PROJECT_NAME
);
897 SWTBotUtils
.deleteProject(DEFAULT_PROJECT_NAME
, fBot
);
902 * Action : Recursive import with preserved folder structure
906 * Procedure : 0) Delete all traces in project
907 * 1) Open Import wizard
908 * 2) Browse to directory ${local}/traces/import/
909 * 3) Select directory import
910 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and select "Preserve Folder Structure"
914 * Expected Results: All matching traces are imported with trace type set.
915 * The folder "clashes" is imported with traces inside. Make sure that the
916 * traces can be opened.
919 public void test3_29ImportRecursivePreserve() {
920 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
922 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
923 importTrace(CUSTOM_TEXT_TRACE_TYPE
, optionFlags
, ImportConfirmation
.CONTINUE
, "");
925 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
, CUSTOM_TEXT_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
926 verifyTrace(CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, CUSTOM_XML_LOG_AS_TEXT
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
927 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
, UNRECOGNIZED_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
928 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, CLASHES_CUSTOM_TEXT_LOG
.getTracePath(), CUSTOM_TEXT_TRACE_TYPE
);
929 verifyTrace(CLASHES_CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, CLASHES_CUSTOM_XML_LOG_AS_TEXT
.getTracePath(), CUSTOM_TEXT_TRACE_TYPE
);
931 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
932 assertEquals(4, tracesFolderItem
.getItems().length
);
933 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
934 assertEquals(2, clashesFolderItem
.getItems().length
);
939 * Action : Recursive import with preserved folder structure (Skip All)
943 * Procedure : 1) Open Import wizard
944 * 2) Browse to directory ${local}/traces/import/
945 * 3) Select directory import
946 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and select "Preserve Folder Structure"
948 * 6) When dialog appears select "Skip All"
951 * Expected Results: The wizard should finish quickly as no trace will be
952 * imported. Make sure that the traces can be opened.
955 public void test3_30ImportRecursivePreserveSkipAll() {
956 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
957 importTrace(CUSTOM_TEXT_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
959 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
, CUSTOM_TEXT_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
960 verifyTrace(CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, CUSTOM_XML_LOG_AS_TEXT
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
961 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
, UNRECOGNIZED_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
962 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, CLASHES_CUSTOM_TEXT_LOG
.getTracePath(), CUSTOM_TEXT_TRACE_TYPE
);
963 verifyTrace(CLASHES_CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, CLASHES_CUSTOM_XML_LOG_AS_TEXT
.getTracePath(), CUSTOM_TEXT_TRACE_TYPE
);
965 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
966 assertEquals(4, tracesFolderItem
.getItems().length
);
967 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
968 assertEquals(2, clashesFolderItem
.getItems().length
);
969 //TOOD: verify that traces were actually skipped
974 * Action : Recursive import with preserved folder structure (Rename All)
978 * Procedure : 1) Open Import wizard
979 * 2) Browse to directory ${local}/traces/import/
980 * 3) Select directory import
981 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and select "Preserve Folder Structure"
983 * 6) When dialog appears select "Rename All"
986 * Expected Results: All matching traces are imported with trace type set.
987 * The traces are renamed with suffix (2). The folder "clashes" is imported
988 * with traces inside. Make sure that the traces can be opened.
991 public void test3_31ImportRecursivePreserveRenameAll() {
992 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
993 importTrace(CUSTOM_TEXT_TRACE_TYPE
, optionFlags
, ImportConfirmation
.RENAME_ALL
, "");
995 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
, toRenamedName(CUSTOM_TEXT_LOG
.getTraceName()), CUSTOM_TEXT_TRACE_TYPE
);
996 verifyTrace(CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, toRenamedName(CUSTOM_XML_LOG_AS_TEXT
.getTraceName()), CUSTOM_TEXT_TRACE_TYPE
);
997 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
, toRenamedName(UNRECOGNIZED_LOG
.getTraceName()), CUSTOM_TEXT_TRACE_TYPE
);
998 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, toRenamedName(CLASHES_CUSTOM_TEXT_LOG
.getTracePath()), CUSTOM_TEXT_TRACE_TYPE
);
999 verifyTrace(CLASHES_CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, toRenamedName(CLASHES_CUSTOM_XML_LOG_AS_TEXT
.getTracePath()), CUSTOM_TEXT_TRACE_TYPE
);
1001 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1002 assertEquals(7, tracesFolderItem
.getItems().length
);
1003 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
1004 assertEquals(4, clashesFolderItem
.getItems().length
);
1009 * Action : Delete with mixed selection of traces and folder
1013 * Procedure : 0) Delete all traces in project
1014 * 1) Create two trace folders under the "Traces" folder
1015 * 2) Import 2 traces under each folder
1016 * 3) Open all 4 traces.
1017 * 4) Select the trace in the first folder and the second folder in the Project Explorer view
1018 * 5) Right-click, Delete. Click Yes.
1021 * Expected Results: A dialog should ask the user to confirm deletion of the
1022 * selected elements. Clicking OK should remove all that was selected. The
1023 * editor of the 3 deleted traces should be closed automatically with one
1024 * remaining editor opened.
1027 public void test3_32DeleteTraceAndFolder() {
1028 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1030 SWTBotTreeItem tracesFolder
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1031 tracesFolder
.contextMenu().menu("New Folder...").click();
1032 SWTBot newFolderShellBot
= fBot
.shell("New Folder").bot();
1033 newFolderShellBot
.text().setText("FolderA");
1034 newFolderShellBot
.button("OK").click();
1035 tracesFolder
.contextMenu().menu("New Folder...").click();
1036 newFolderShellBot
= fBot
.shell("New Folder").bot();
1037 newFolderShellBot
.text().setText("FolderB");
1038 newFolderShellBot
.button("OK").click();
1040 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
1041 SWTBotTreeItem traceFolder
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolder
, "FolderA");
1042 SWTBotShell shell
= openTraceFoldersImport(traceFolder
);
1043 importTrace(shell
, null, null, optionFlags
, new ImportConfirmationSupplier(), CUSTOM_TEXT_LOG
.getTracePath(), LTTNG_KERNEL_TRACE
.getTracePath());
1044 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
, "FolderA/" + CUSTOM_TEXT_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
1045 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
, "FolderA/" + LTTNG_KERNEL_TRACE
.getTraceName(), LTTNG_KERNEL_TRACE_TYPE
);
1047 traceFolder
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolder
, "FolderB");
1048 shell
= openTraceFoldersImport(traceFolder
);
1049 importTrace(shell
, null, null, optionFlags
, new ImportConfirmationSupplier(), CUSTOM_TEXT_LOG
.getTracePath(), LTTNG_KERNEL_TRACE
.getTracePath());
1050 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
, "FolderB/" + CUSTOM_TEXT_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
1051 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
, "FolderB/" + LTTNG_KERNEL_TRACE
.getTraceName(), LTTNG_KERNEL_TRACE_TYPE
);
1053 SWTBotTree tree
= fBot
.viewByTitle("Project Explorer").bot().tree();
1054 SWTBotTreeItem folderAItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolder
, "FolderA");
1055 SWTBotTreeItem traceItem
= SWTBotUtils
.getTraceProjectItem(fBot
, folderAItem
, CUSTOM_TEXT_LOG
.getTraceName());
1056 SWTBotTreeItem folderBItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolder
, "FolderB");
1057 tree
.select(traceItem
, folderBItem
);
1058 tree
.contextMenu().menu("Delete").click();
1059 SWTBot deleteConfirmationShellBot
= fBot
.shell("Confirm Delete").bot();
1060 deleteConfirmationShellBot
.button("Yes").click();
1061 fBot
.waitWhile(ConditionHelpers
.isEditorOpened(fBot
, "FolderA/" + CUSTOM_TEXT_LOG
.getTraceName()));
1062 fBot
.waitWhile(ConditionHelpers
.isEditorOpened(fBot
, "FolderB/" + CUSTOM_TEXT_LOG
.getTraceName()));
1063 fBot
.waitWhile(ConditionHelpers
.isEditorOpened(fBot
, "FolderB/" + LTTNG_KERNEL_TRACE
.getTraceName()));
1064 fBot
.waitUntil(ConditionHelpers
.isEditorOpened(fBot
, "FolderA/" + LTTNG_KERNEL_TRACE
.getTraceName()));
1065 assertEquals(1, tracesFolder
.getNodes().size());
1066 assertEquals(1, folderAItem
.getNodes().size());
1071 * Action : Delete with multiple folders
1075 * Procedure : 0) Delete all traces in project
1076 * 1) Create two trace folders under the "Traces" folder
1077 * 2) Import a trace under each folder
1078 * 3) Open both traces.
1079 * 4) Select both folders in the Project Explorer view
1080 * 5) Right-click, Delete. Click Yes.
1083 * Expected Results: A dialog should ask the user to confirm deletion of the
1084 * selected elements. Clicking OK should remove all that was selected. The
1085 * editor of the 3 deleted traces should be closed automatically with one
1086 * remaining editor opened.
1089 public void test3_33DeleteMultipleFolders() {
1090 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1092 SWTBotTreeItem tracesFolder
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1093 tracesFolder
.contextMenu().menu("New Folder...").click();
1094 SWTBot newFolderShellBot
= fBot
.shell("New Folder").bot();
1095 newFolderShellBot
.text().setText("FolderA");
1096 newFolderShellBot
.button("OK").click();
1097 tracesFolder
.contextMenu().menu("New Folder...").click();
1098 newFolderShellBot
= fBot
.shell("New Folder").bot();
1099 newFolderShellBot
.text().setText("FolderB");
1100 newFolderShellBot
.button("OK").click();
1102 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
1103 SWTBotTreeItem traceFolder
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolder
, "FolderA");
1104 SWTBotShell shell
= openTraceFoldersImport(traceFolder
);
1105 importTrace(shell
, null, null, optionFlags
, new ImportConfirmationSupplier(), CUSTOM_TEXT_LOG
.getTracePath());
1106 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
, "FolderA/" + CUSTOM_TEXT_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
1108 traceFolder
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolder
, "FolderB");
1109 shell
= openTraceFoldersImport(traceFolder
);
1110 importTrace(shell
, null, null, optionFlags
, new ImportConfirmationSupplier(), LTTNG_KERNEL_TRACE
.getTracePath());
1111 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
, "FolderB/" + LTTNG_KERNEL_TRACE
.getTraceName(), LTTNG_KERNEL_TRACE_TYPE
);
1113 SWTBotTree tree
= fBot
.viewByTitle("Project Explorer").bot().tree();
1114 SWTBotTreeItem folderAItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolder
, "FolderA");
1115 SWTBotTreeItem folderBItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolder
, "FolderB");
1116 tree
.select(folderAItem
, folderBItem
);
1117 tree
.contextMenu().menu("Delete").click();
1118 SWTBot deleteConfirmationShellBot
= fBot
.shell("Confirm Delete").bot();
1119 deleteConfirmationShellBot
.button("Yes").click();
1120 fBot
.waitWhile(ConditionHelpers
.isEditorOpened(fBot
, "FolderA/" + CUSTOM_TEXT_LOG
.getTraceName()));
1121 fBot
.waitWhile(ConditionHelpers
.isEditorOpened(fBot
, "FolderB/" + LTTNG_KERNEL_TRACE
.getTraceName()));
1122 assertEquals(0, tracesFolder
.getNodes().size());
1127 * Action : Clear single Traces folder
1131 * Procedure : 1) Import 2 traces from different folders preserving folder structure
1132 * 2) Open both traces.
1133 * 3) Select the Traces folder
1134 * 4) Right-click, Clear. Click Yes.
1137 * Expected Results: A dialog should ask the user to confirm clearing of the
1138 * folder. Clicking Yes should remove everything under the selected folder
1139 * and close the traces.
1142 public void test3_34ClearSingleTracesFolder() {
1143 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
1144 importTrace(CUSTOM_TEXT_TRACE_TYPE
, optionFlags
, ImportConfirmation
.CONTINUE
, CUSTOM_TEXT_LOG
.getTraceName(), CLASHES_CUSTOM_TEXT_LOG
.getTracePath());
1146 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
, CUSTOM_TEXT_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
1147 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, CLASHES_CUSTOM_TEXT_LOG
.getTracePath(), CUSTOM_TEXT_TRACE_TYPE
);
1149 SWTBotTreeItem tracesFolder
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1150 tracesFolder
.contextMenu().menu("Clear").click();
1151 SWTBot deleteConfirmationShellBot
= fBot
.shell("Confirm Clear").bot();
1152 deleteConfirmationShellBot
.button("Yes").click();
1153 fBot
.waitWhile(ConditionHelpers
.isEditorOpened(fBot
, CUSTOM_TEXT_LOG
.getTraceName()));
1154 fBot
.waitWhile(ConditionHelpers
.isEditorOpened(fBot
, CLASHES_CUSTOM_TEXT_LOG
.getTracePath()));
1155 assertEquals(0, tracesFolder
.getNodes().size());
1160 * Action : Clear multiple Traces folder
1164 * Procedure : 1) Import 2 traces to different projects
1165 * 2) Open both traces.
1166 * 3) Select both Traces folders
1167 * 4) Right-click, Clear. Click Yes.
1170 * Expected Results: A dialog should ask the user to confirm clearing of the
1171 * folders. Clicking Yes should remove everything under the selected folders
1172 * and close the traces.
1175 public void test3_35ClearMultipleTracesFolder() {
1176 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
1177 SWTBotTreeItem tracesFolder1
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1178 SWTBotShell shell
= openTraceFoldersImport(tracesFolder1
);
1179 importTrace(shell
, null, null, optionFlags
, new ImportConfirmationSupplier(), CUSTOM_TEXT_LOG
.getTracePath());
1180 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
, CUSTOM_TEXT_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
, TRACE_PROJECT_NAME
);
1182 SWTBotUtils
.createProject(DEFAULT_PROJECT_NAME
);
1183 SWTBotTreeItem tracesFolder2
= SWTBotUtils
.selectTracesFolder(fBot
, DEFAULT_PROJECT_NAME
);
1184 shell
= openTraceFoldersImport(tracesFolder2
);
1185 importTrace(shell
, null, null, optionFlags
, new ImportConfirmationSupplier(), LTTNG_KERNEL_TRACE
.getTracePath());
1186 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
, LTTNG_KERNEL_TRACE
.getTraceName(), LTTNG_KERNEL_TRACE_TYPE
, DEFAULT_PROJECT_NAME
);
1188 SWTBotTree tree
= fBot
.viewByTitle("Project Explorer").bot().tree();
1189 tree
.select(tracesFolder1
, tracesFolder2
);
1190 tree
.contextMenu().menu("Clear").click();
1191 SWTBot deleteConfirmationShellBot
= fBot
.shell("Confirm Clear").bot();
1192 deleteConfirmationShellBot
.button("Yes").click();
1193 fBot
.waitWhile(ConditionHelpers
.isEditorOpened(fBot
, CUSTOM_TEXT_LOG
.getTraceName()));
1194 fBot
.waitWhile(ConditionHelpers
.isEditorOpened(fBot
, LTTNG_KERNEL_TRACE
.getTraceName()));
1195 assertEquals(0, tracesFolder1
.getNodes().size());
1196 assertEquals(0, tracesFolder2
.getNodes().size());
1198 SWTBotUtils
.deleteProject(DEFAULT_PROJECT_NAME
, fBot
);
1203 * Action : Import from zip archive with preserved folder structure
1207 * Procedure : 0) Delete all traces in project
1208 * 1) Open Import wizard
1209 * 2) Select archive file: traces.zip
1210 * 3) Select archive root directory
1211 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
1215 * Expected Results: All traces are imported with trace type set. The folder
1216 * "clashes" is imported with traces inside. Make sure that the traces can
1220 public void test3_36ImportZipArchivePreserve() {
1221 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1223 int optionFlags
= ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
1224 importTrace("traces.zip", null, optionFlags
, ImportConfirmation
.CONTINUE
, "");
1226 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
1227 verifyTrace(info
, optionFlags
, info
.getTracePath());
1230 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1231 assertEquals(7, tracesFolderItem
.getItems().length
);
1232 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
1233 assertEquals(6, clashesFolderItem
.getItems().length
);
1238 * Action : Import from zip archive without preserved folder structure
1243 * Procedure : 0) Delete all traces in project
1244 * 1) Open Import wizard
1245 * 2) Select archive file: traces.zip
1246 * 3) Select archive root directory
1247 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and unselect "Preserve Folder Structure"
1249 * 6) When dialog appears select "Rename All"
1252 * Expected Results: All traces are imported with trace type set. The traces
1253 * from folder "clashes" are renamed with suffix (2). Make sure that the
1254 * traces can be opened.
1257 public void test3_37ImportZipArchiveNoPreserve() {
1258 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1260 int optionFlags
= 0;
1261 importTrace("traces.zip", null, optionFlags
, ImportConfirmation
.RENAME_ALL
, "");
1263 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
1264 String traceName
= info
.getTraceName();
1265 if (CLASHING_TRACEINFOS
.contains(info
)) {
1266 traceName
= toRenamedName(traceName
);
1268 verifyTrace(info
, optionFlags
, traceName
);
1271 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1272 assertEquals(12, tracesFolderItem
.getItems().length
);
1277 * Action : Import from zip archive specific traces
1281 * Procedure : 0) Delete all traces in project
1282 * 1) Open Import wizard
1283 * 2) Select archive file: traces.zip
1284 * 3) Select file z-clashes/ExampleCustomTxt.log and directory kernel-overlap-testing/
1285 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
1289 * Expected Results: The specified traces are imported with trace type set.
1290 * Make sure that the traces can be opened.
1293 public void test3_38ImportZipArchiveSpecificTraces() {
1294 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1296 int optionFlags
= ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
1297 importTrace("traces.zip", null, optionFlags
, ImportConfirmation
.CONTINUE
, "z-clashes/ExampleCustomTxt.log", "kernel-overlap-testing/");
1299 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, CLASHES_CUSTOM_TEXT_LOG
.getTracePath());
1300 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
, LTTNG_KERNEL_TRACE
.getTracePath());
1302 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1303 assertEquals(2, tracesFolderItem
.getItems().length
);
1304 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
1305 assertEquals(1, clashesFolderItem
.getItems().length
);
1310 * Action : Import from tar.gz archive with preserved folder structure
1314 * Procedure : 0) Delete all traces in project
1315 * 1) Open Import wizard
1316 * 2) Select archive file: traces.tar.gz
1317 * 3) Select archive root directory
1318 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
1322 * Expected Results: All traces are imported with trace type set. The folder
1323 * "clashes" is imported with traces inside. Make sure that the traces can
1327 public void test3_39ImportTarGzipArchivePreserve() {
1328 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1330 int optionFlags
= ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
1331 importTrace("traces.tar.gz", null, optionFlags
, ImportConfirmation
.CONTINUE
, "");
1333 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
1334 verifyTrace(info
, optionFlags
, info
.getTracePath());
1337 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1338 assertEquals(7, tracesFolderItem
.getItems().length
);
1339 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
1340 assertEquals(6, clashesFolderItem
.getItems().length
);
1345 * Action : Import from tar.gz archive without preserved folder structure (Rename All)
1349 * Procedure : 0) Delete all traces in project
1350 * 1) Open Import wizard
1351 * 2) Select archive file: traces.tar.gz
1352 * 3) Select archive root directory
1353 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and unselect "Preserve Folder Structure"
1355 * 6) When dialog appears select "Rename All"
1358 * Expected Results: All traces are imported with trace type set. The traces
1359 * from folder "clashes" are renamed with suffix (2). Make sure that the
1360 * traces can be opened.
1363 public void test3_40ImportTarGzipArchiveNoPreserve() {
1364 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1366 int optionFlags
= 0;
1367 importTrace("traces.tar.gz", null, optionFlags
, ImportConfirmation
.RENAME_ALL
, "");
1369 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
1370 String traceName
= info
.getTraceName();
1371 if (CLASHING_TRACEINFOS
.contains(info
)) {
1372 traceName
= toRenamedName(traceName
);
1374 verifyTrace(info
, optionFlags
, traceName
);
1377 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1378 assertEquals(12, tracesFolderItem
.getItems().length
);
1383 * Action : Import from tar.gz archive specific traces
1387 * Procedure : 0) Delete all traces in project
1388 * 1) Open Import wizard
1389 * 2) Select archive file: traces.tar.gz
1390 * 3) Select file z-clashes/ExampleCustomTxt.log and directory kernel-overlap-testing/
1391 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
1395 * Expected Results: The specified traces are imported with trace type set.
1396 * Make sure that the traces can be opened.
1399 public void test3_41ImportTarGzipArchiveSpecificTraces() {
1400 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1402 int optionFlags
= ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
1403 importTrace("traces.tar.gz", null, optionFlags
, ImportConfirmation
.CONTINUE
, "z-clashes/ExampleCustomTxt.log", "kernel-overlap-testing/");
1405 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, CLASHES_CUSTOM_TEXT_LOG
.getTracePath());
1406 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
, LTTNG_KERNEL_TRACE
.getTracePath());
1408 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1409 assertEquals(2, tracesFolderItem
.getItems().length
);
1410 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
1411 assertEquals(1, clashesFolderItem
.getItems().length
);
1414 private static void verifyTrace(TestTraceInfo traceInfo
, int importOptionFlags
) {
1415 verifyTrace(traceInfo
, importOptionFlags
, traceInfo
.getTraceName());
1418 private static void verifyTrace(TestTraceInfo traceInfo
, int importOptionFlags
, String traceName
) {
1419 verifyTrace(traceInfo
, importOptionFlags
, traceName
, traceInfo
.getTraceType());
1422 private static void verifyTrace(TestTraceInfo traceInfo
, int importOptionFlags
, String traceName
, String traceType
) {
1423 verifyTrace(traceInfo
, importOptionFlags
, traceName
, traceType
, TRACE_PROJECT_NAME
);
1426 private static void verifyTrace(TestTraceInfo traceInfo
, int importOptionFlags
, String traceName
, String traceType
, String projectName
) {
1427 String
[] tracePath
= new Path(traceName
).segments();
1428 SWTBotTreeItem traceItem
= SWTBotUtils
.getTraceProjectItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, projectName
), tracePath
);
1429 checkTraceType(traceItem
, traceType
);
1430 openTrace(traceItem
);
1431 if (traceType
!= null && !traceType
.isEmpty()) {
1432 SWTBotImportWizardUtils
.testEventsTable(fBot
, traceName
, traceInfo
.getNbEvents(), traceInfo
.getFirstEventTimestamp());
1434 // If there is no trace type, make sure it can be opened with the text editor
1435 fBot
.waitUntil(ConditionHelpers
.isEditorOpened(fBot
, traceName
));
1436 SWTBotEditor editor
= fBot
.editorByTitle(traceName
);
1437 assertEquals(TEXT_EDITOR_ID
, editor
.getReference().getId());
1439 checkTraceLinked(traceItem
, (importOptionFlags
& ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
) != 0);
1442 private static String
toRenamedName(String traceName
) {
1443 return traceName
+ "(2)";
1446 private static void openTrace(SWTBotTreeItem traceItem
) {
1448 traceItem
.doubleClick();
1451 private static void testSingleTrace(TestTraceInfo traceInfo
, int optionFlags
) {
1452 importTrace(optionFlags
, traceInfo
.getTracePath());
1453 verifyTrace(traceInfo
, optionFlags
);
1456 private static void importTrace(int optionFlags
, String
... tracePaths
) {
1457 importTrace(optionFlags
, ImportConfirmation
.CONTINUE
, tracePaths
);
1460 private static void importTrace(int optionFlags
, ImportConfirmation confirmationMode
, String
... tracePaths
) {
1461 importTrace(null, optionFlags
, confirmationMode
, tracePaths
);
1464 private static void importTrace(String traceType
, int optionFlags
, ImportConfirmation confirmationMode
, String
... tracePaths
) {
1465 importTrace(null, traceType
, optionFlags
, confirmationMode
, tracePaths
);
1468 private static void importTrace(String archiveFile
, String traceType
, int optionFlags
, ImportConfirmation confirmationMode
, String
... tracePaths
) {
1469 importTrace(archiveFile
, traceType
, optionFlags
, new ImportConfirmationSupplier(confirmationMode
), tracePaths
);
1472 private static void importTrace(int optionFlags
, Supplier
<ImportConfirmation
> confirmationSuplier
, String
... tracePaths
) {
1473 importTrace(null, null, optionFlags
, confirmationSuplier
, tracePaths
);
1476 private static void importTrace(String archiveFile
, String traceType
, int optionFlags
, Supplier
<ImportConfirmation
> confirmationSuplier
, String
... tracePaths
) {
1477 SWTBotTreeItem traceFolder
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1478 SWTBotShell shell
= openTraceFoldersImport(traceFolder
);
1479 importTrace(shell
, archiveFile
, traceType
, optionFlags
, confirmationSuplier
, tracePaths
);
1483 * @param tracePaths relative to parent test traces folder
1485 private static void importTrace(SWTBotShell shell
, String archiveFile
, String traceType
, int optionFlags
, Supplier
<ImportConfirmation
> confirmationSuplier
, String
... tracePaths
) {
1486 SWTBot bot
= shell
.bot();
1487 String rootFolderName
;
1488 if (archiveFile
== null) {
1489 rootFolderName
= "import";
1490 String importDirectoryFullPath
= getPath(rootFolderName
);
1491 SWTBotImportWizardUtils
.selectImportFromDirectory(bot
, importDirectoryFullPath
);
1493 rootFolderName
= "/";
1494 String importArchiveFullPath
= getPath("archives" + File
.separator
+ archiveFile
);
1495 SWTBotImportWizardUtils
.selectImportFromArchive(bot
, importArchiveFullPath
);
1498 for (String tracePath
: tracePaths
) {
1499 IPath somePath
= new Path(rootFolderName
).append(tracePath
);
1500 String
[] treePath
= somePath
.segments();
1501 if (archiveFile
!= null) {
1502 String
[] newPath
= new String
[treePath
.length
+ 1];
1504 System
.arraycopy(treePath
, 0, newPath
, 1, treePath
.length
);
1507 SWTBotImportWizardUtils
.selectItem(fBot
, treePath
);
1510 SWTBotImportWizardUtils
.setOptions(bot
, optionFlags
, traceType
);
1511 bot
.button("Finish").click();
1513 ImportConfirmation importConfirmation
= confirmationSuplier
.get();
1514 while (importConfirmation
!= null) {
1515 if (importConfirmation
!= ImportConfirmation
.CONTINUE
) {
1516 fBot
.waitUntil(Conditions
.shellIsActive("Confirmation"));
1517 SWTBotShell shell2
= fBot
.activeShell();
1518 SWTBotButton button
= shell2
.bot().button(importConfirmation
.getInName());
1521 importConfirmation
= confirmationSuplier
.get();
1524 fBot
.waitUntil(Conditions
.shellCloses(shell
));
1527 private static void checkTraceType(SWTBotTreeItem traceItem
, String traceType
) {
1528 assertEquals(traceType
, getTraceProperty(traceItem
, "type"));
1531 private static void checkTraceLinked(SWTBotTreeItem traceItem
, boolean linked
) {
1532 assertEquals(Boolean
.toString(linked
), getTraceProperty(traceItem
, "linked"));
1535 private static String
getTraceProperty(SWTBotTreeItem traceItem
, String property
) {
1536 SWTBotUtils
.openView(IPageLayout
.ID_PROP_SHEET
);
1537 SWTBotView view
= fBot
.viewById(IPageLayout
.ID_PROP_SHEET
);
1540 SWTBotTreeItem traceTypeItem
= SWTBotUtils
.getTreeItem(view
.bot(), view
.bot().tree(), "Resource properties", property
);
1541 return traceTypeItem
.cell(1);
1544 private static SWTBotShell
openTraceFoldersImport(SWTBotTreeItem traceItem
) {
1545 traceItem
.contextMenu().menu("Import...").click();
1546 fBot
.waitUntil(Conditions
.shellIsActive("Trace Import"));
1548 SWTBotShell shell
= fBot
.shell("Trace Import");
1552 private static SWTBotShell
openWorkbenchMenuImport() {
1553 fBot
.menu().menu("File", "Import...").click();
1554 fBot
.waitUntil(Conditions
.shellIsActive("Import"));
1556 SWTBot shellBot
= fBot
.shell("Import").bot();
1557 SWTBotTree tree
= shellBot
.tree();
1558 SWTBotUtils
.getTreeItem(fBot
, tree
, "Tracing", "Trace Import").select();
1559 shellBot
.button("Next >").click();
1560 SWTBotShell shell
= fBot
.shell("Trace Import");