1 /******************************************************************************
2 * Copyright (c) 2016 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
.SWTBotTreeItem
;
36 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
.ImportConfirmation
;
37 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
.ImportTraceWizardPage
;
38 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTxtTraceDefinition
;
39 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomXmlTraceDefinition
;
40 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
41 import org
.eclipse
.tracecompass
.tmf
.ctf
.ui
.swtbot
.tests
.SWTBotImportWizardUtils
;
42 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.ConditionHelpers
;
43 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.SWTBotUtils
;
44 import org
.eclipse
.tracecompass
.tmf
.ui
.tests
.shared
.WaitUtils
;
45 import org
.eclipse
.ui
.IPageLayout
;
46 import org
.junit
.After
;
47 import org
.junit
.AfterClass
;
48 import org
.junit
.BeforeClass
;
49 import org
.junit
.FixMethodOrder
;
50 import org
.junit
.Test
;
51 import org
.junit
.runner
.RunWith
;
52 import org
.junit
.runners
.MethodSorters
;
54 import com
.google
.common
.collect
.ImmutableList
;
55 import com
.google
.common
.collect
.ImmutableSet
;
58 * SWTBot test for testing Project Explorer trace folders (context-menu,
61 @RunWith(SWTBotJunit4ClassRunner
.class)
62 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
63 @SuppressWarnings({"restriction", "javadoc"})
64 public class ProjectExplorerTracesFolderTest
{
66 private static final String PROP_LAST_MODIFIED_PROPERTY
= "last modified";
67 private static final String TEXT_EDITOR_ID
= "org.eclipse.ui.DefaultTextEditor";
69 private static final String GENERIC_CTF_TRACE_TYPE
= "Common Trace Format : Generic CTF Trace";
70 private static final String LTTNG_KERNEL_TRACE_TYPE
= "Common Trace Format : Linux Kernel Trace";
71 private static final String LTTNG_UST_TRACE_TYPE
= "Common Trace Format : LTTng UST Trace";
72 private static final String CUSTOM_TEXT_TRACE_TYPE
= "Custom Text : TmfGeneric";
73 private static final String CUSTOM_XML_TRACE_TYPE
= "Custom XML : Custom XML Log";
75 private static final @NonNull TestTraceInfo CUSTOM_TEXT_LOG
= new TestTraceInfo("ExampleCustomTxt.log", CUSTOM_TEXT_TRACE_TYPE
, 10, "29:52.034");
76 private static final @NonNull TestTraceInfo CUSTOM_XML_LOG
= new TestTraceInfo("ExampleCustomXml.xml", CUSTOM_XML_TRACE_TYPE
, 6, "22:01:20");
77 private static final @NonNull TestTraceInfo LTTNG_KERNEL_TRACE
= new TestTraceInfo("kernel-overlap-testing", LTTNG_KERNEL_TRACE_TYPE
, 1000, "04:32.650 993 664");
78 private static final @NonNull TestTraceInfo SIMPLE_SERVER1_UST_TRACE
= new TestTraceInfo("simple_server-thread1", LTTNG_UST_TRACE_TYPE
, 1000, "04:32.650 993 664");
79 private static final @NonNull TestTraceInfo SIMPLE_SERVER2_UST_TRACE
= new TestTraceInfo("simple_server-thread2", LTTNG_UST_TRACE_TYPE
, 1000, "04:32.650 993 664");
80 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");
82 private static final String CLASHES_DIR_NAME
= "z-clashes";
83 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");
84 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");
85 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");
86 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");
87 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");
88 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");
91 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(),
92 LTTNG_KERNEL_TRACE
.getFirstEventTimestamp());
93 private static final @NonNull TestTraceInfo UNRECOGNIZED_LOG
= new TestTraceInfo("unrecognized.log", "", 0, "");
94 private static final @NonNull TestTraceInfo CUSTOM_XML_LOG_AS_TEXT
= new TestTraceInfo("ExampleCustomXml.xml", CUSTOM_TEXT_TRACE_TYPE
, 0, "");
95 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, "");
97 private static final TestTraceInfo
[] ALL_TRACEINFOS
= new TestTraceInfo
[] {
101 SIMPLE_SERVER1_UST_TRACE
,
102 SIMPLE_SERVER2_UST_TRACE
,
103 UST_OVERLAP_TESTING_UST_TRACE
,
105 CLASHES_CUSTOM_TEXT_LOG
,
106 CLASHES_CUSTOM_XML_LOG
,
107 CLASHES_LTTNG_KERNEL_TRACE
,
108 CLASHES_SIMPLE_SERVER1_UST_TRACE
,
109 CLASHES_SIMPLE_SERVER2_UST_TRACE
,
110 CLASHES_UST_OVERLAP_TESTING_UST_TRACE
113 private static final Set
<TestTraceInfo
> CLASHING_TRACEINFOS
= ImmutableSet
.of(
114 CLASHES_CUSTOM_TEXT_LOG
,
115 CLASHES_CUSTOM_XML_LOG
,
116 CLASHES_LTTNG_KERNEL_TRACE
,
117 CLASHES_SIMPLE_SERVER1_UST_TRACE
,
118 CLASHES_SIMPLE_SERVER2_UST_TRACE
,
119 CLASHES_UST_OVERLAP_TESTING_UST_TRACE
);
121 // All normal traces plus the unrecognized trace
122 private static final int NUM_UNIQUE_TRACES
= CLASHING_TRACEINFOS
.size() + 1;
125 private static final File TEST_TRACES_PATH
= new File(new Path(TmfTraceManager
.getTemporaryDirPath()).append("testtraces").toOSString());
126 private static final String TRACE_PROJECT_NAME
= "test";
127 private static final String MANAGE_CUSTOM_PARSERS_SHELL_TITLE
= "Manage Custom Parsers";
129 private static SWTWorkbenchBot fBot
;
131 /** The Log4j logger instance. */
132 private static final Logger fLogger
= Logger
.getRootLogger();
134 private static String
getPath(String relativePath
) {
135 return new Path(TEST_TRACES_PATH
.getAbsolutePath()).append(relativePath
).toOSString();
141 * @throws IOException
144 public static void init() throws IOException
{
145 TestDirectoryStructureUtil
.generateTraceStructure(TEST_TRACES_PATH
);
147 SWTBotUtils
.initialize();
149 /* Set up for swtbot */
150 SWTBotPreferences
.TIMEOUT
= 20000; /* 20 second timeout */
151 SWTBotPreferences
.KEYBOARD_LAYOUT
= "EN_US";
152 fLogger
.removeAllAppenders();
153 fLogger
.addAppender(new NullAppender());
154 fBot
= new SWTWorkbenchBot();
156 SWTBotUtils
.closeView("Welcome", fBot
);
158 SWTBotUtils
.switchToTracingPerspective();
160 /* Finish waiting for eclipse to load */
161 WaitUtils
.waitForJobs();
162 SWTBotUtils
.createProject(TRACE_PROJECT_NAME
);
166 * Test class tear down method.
169 public static void tearDown() {
170 SWTBotUtils
.deleteProject(TRACE_PROJECT_NAME
, fBot
);
171 fLogger
.removeAllAppenders();
175 * Test tear down method.
178 public void afterTest() {
179 SWTBotUtils
.closeSecondaryShells(fBot
);
182 private static void test3_01Preparation() {
183 // 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
184 CustomTxtTraceDefinition
[] txtDefinitions
= CustomTxtTraceDefinition
.loadAll(getPath("customParsers/ExampleCustomTxtParser.xml"));
185 txtDefinitions
[0].save();
186 CustomXmlTraceDefinition
[] xmlDefinitions
= CustomXmlTraceDefinition
.loadAll(getPath("customParsers/ExampleCustomXmlParser.xml"));
187 xmlDefinitions
[0].save();
189 SWTBotTreeItem traceFolder
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
190 traceFolder
.contextMenu("Manage Custom Parsers...").click();
191 fBot
.waitUntil(Conditions
.shellIsActive(MANAGE_CUSTOM_PARSERS_SHELL_TITLE
));
192 SWTBotShell shell
= fBot
.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE
);
193 SWTBot shellBot
= shell
.bot();
195 // Make sure the custom text trace type is imported
196 shellBot
.list().select(CUSTOM_TEXT_LOG
.getTraceType());
198 // Make sure the custom xml trace type is imported
199 shellBot
.radio("XML").click();
200 shellBot
.list().select(CUSTOM_XML_LOG
.getTraceType());
201 shellBot
.button("Close").click();
202 shellBot
.waitUntil(Conditions
.shellCloses(shell
));
206 * Test that the expected context menu items are there
208 * Action : Trace Folder menu
210 * Procedure :Select the Traces folder and open its context menu
212 * Expected Results: Correct menu opens (Import, Refresh, etc)
215 public void test3_01ContextMenuPresence() {
216 test3_01Preparation();
218 SWTBotTreeItem traceItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
220 final List
<String
> EXPECTED_MENU_LABELS
= ImmutableList
.of(
228 "Import Trace Package...",
229 "Fetch Remote Traces...",
231 "Export Trace Package...",
233 "Manage Custom Parsers...",
234 "Manage XML analyses...",
236 "Apply Time Offset...",
241 List
<String
> menuLabels
= traceItem
.contextMenu().menuItems();
242 for (int i
= 0; i
< menuLabels
.size(); i
++) {
243 assertEquals(EXPECTED_MENU_LABELS
.get(i
), menuLabels
.get(i
));
246 fBot
.closeAllEditors();
250 * Test that the trace import wizard appears
252 * Action : Trace Import Wizard
254 * Procedure : Select Import
256 * Expected Results: Trace Import Wizard appears
259 public void test3_02Import() {
260 SWTBotTreeItem traceItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
262 SWTBotShell shell
= openTraceFoldersImport(traceItem
);
263 shell
.bot().button("Cancel").click();
267 * Test that the trace import wizard can import a single custom text trace
269 * Action : Import single custom text trace (link to workspace)
272 * Procedure : 1) Browse to directory ${local}/traces/import/
273 * 2) Select trace ExampleCustomTxt.log
274 * 3) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning" and select "Create Links to workspace" and
278 * Expected Results: Imported trace appear in Traces Folder and the Trace Type Tmf Generic is set. Make sure trace can be opened
281 public void test3_03SingleCustomTextTrace() {
282 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
283 testSingleTrace(CUSTOM_TEXT_LOG
, optionFlags
);
288 * Action : Import Single custom XML trace (link to workspace)
292 * Procedure : redo 3.1-3.3 but this time select ExampleCustomXml.xml
295 * Expected Results: Imported trace appear in Traces Folder and the Trace
296 * Type "Custom XML log" is set. Make sure that trace can be opened
299 public void test3_04SingleCustomXmlTrace() {
300 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
301 testSingleTrace(CUSTOM_XML_LOG
, optionFlags
);
306 * Action : Import LTTng Kernel CTF trace (link to workspace)
310 * Procedure : redo 3.1-3.3 but this time select directory kernel-overlap-testing/
313 * Expected Results: Imported trace appear in Traces Folder and the Trace
314 * Type "LTTng Kernel" is set. Make sure that trace can be opened
317 public void test3_05SingleCtfTrace() {
318 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
319 testSingleTrace(LTTNG_KERNEL_TRACE
, optionFlags
);
324 * Action : Rename + copy import
328 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace"
329 * 2) When dialog box appear select Rename
332 * Expected Results: Traces are imported with new name that has a suffix (2)
333 * at the end. Make sure that imported traces are copied to the project.
336 public void test3_06RenameCopyImport() {
337 testRenameCopyImport(CUSTOM_TEXT_LOG
);
338 testRenameCopyImport(CUSTOM_XML_LOG
);
339 testRenameCopyImport(LTTNG_KERNEL_TRACE
);
342 private static void testRenameCopyImport(TestTraceInfo traceInfo
) {
343 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
;
344 importTrace(optionFlags
, ImportConfirmation
.RENAME
, traceInfo
.getTraceName());
345 String renamed
= toRenamedName(traceInfo
.getTraceName());
346 verifyTrace(traceInfo
, optionFlags
, renamed
);
351 * Action : Overwrite + copy import
355 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace"
356 * 2) When dialog box appear select Overwrite
359 * Expected Results: Existing traces are deleted and new traces are
360 * imported. Make sure that imported traces are copied to the project and
364 public void test3_07OverwriteCopyImport() {
365 testOverwriteCopyImport(CUSTOM_TEXT_LOG
);
366 testOverwriteCopyImport(CUSTOM_XML_LOG
);
367 testOverwriteCopyImport(LTTNG_KERNEL_TRACE
);
370 private static void testOverwriteCopyImport(TestTraceInfo traceInfo
) {
371 String traceName
= traceInfo
.getTraceName();
372 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
), traceName
);
373 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
374 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
;
375 importTrace(optionFlags
, ImportConfirmation
.OVERWRITE
, traceName
);
376 verifyTrace(traceInfo
, optionFlags
);
378 assertNotEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
387 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace"
388 * 2) When dialog box appear select Skip
391 * Expected Results: Make sure that no new trace is imported
394 public void test3_08SkipImport() {
395 testSkipImport(CUSTOM_TEXT_LOG
);
396 testSkipImport(CUSTOM_XML_LOG
);
397 testSkipImport(LTTNG_KERNEL_TRACE
);
400 private static void testSkipImport(TestTraceInfo traceInfo
) {
401 String traceName
= traceInfo
.getTraceName();
402 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
), traceName
);
403 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
404 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
;
405 importTrace(optionFlags
, ImportConfirmation
.SKIP
, traceName
);
406 verifyTrace(traceInfo
, optionFlags
);
408 assertEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
413 * Action : Default overwrite
417 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace" and select "Overwrite existing without warning"
420 * Expected Results: Make sure that no dialog box appears (for renaming,
421 * overwriting, skipping) and existing traces are overwritten). Make sure
422 * trace can be opened
425 public void test3_09OverwriteOptionImport() {
426 testOverwriteOptionImport(CUSTOM_TEXT_LOG
);
427 testOverwriteOptionImport(CUSTOM_XML_LOG
);
428 testOverwriteOptionImport(LTTNG_KERNEL_TRACE
);
431 private static void testOverwriteOptionImport(TestTraceInfo traceInfo
) {
432 String traceName
= traceInfo
.getTraceName();
433 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
), traceName
);
434 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
436 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
;
437 importTrace(optionFlags
, ImportConfirmation
.CONTINUE
, traceName
);
438 verifyTrace(traceInfo
, optionFlags
);
440 assertNotEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
445 * Action : Import unrecognized
449 * Procedure : 1) Open Import wizard (see 3.1-3.2)
450 * 2) Browse to directory ${local}/traces/import
451 * 3) Select trace unrecognized.log
452 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning" and select "Create Links to workspace" and
456 * Expected Results: unrecognized.log is imported with trace type unknown.
457 * The default text file icon is displayed. The trace, when opened, is
458 * displayed in the text editor.
461 public void test3_10ImportUnrecognized() {
462 String traceName
= UNRECOGNIZED_LOG
.getTraceName();
463 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
464 importTrace(optionFlags
, traceName
);
465 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
470 * Action : Import unrecognized (ignore)
474 * Procedure : 1) redo 3.10, however unselect "Import unrecognized traces"
477 * Expected Results: unrecognized.log is not imported
480 public void test3_11ImportUnrecognizedIgnore() {
481 String traceName
= UNRECOGNIZED_LOG
.getTraceName();
482 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
483 int numTraces
= tracesFolderItem
.getItems().length
;
485 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, tracesFolderItem
, traceName
);
486 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
488 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
489 importTrace(optionFlags
, traceName
);
490 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
492 assertEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
493 assertEquals(numTraces
, tracesFolderItem
.getItems().length
);
498 * Action : Import CTF trace by selection metadata file only
502 * Procedure : 1) Redo 3.5, However only select metadata file instead of directory trace
505 * Expected Results: Imported trace appear in Traces Folder and the Trace
506 * Type "LTTng Kernel" is set. Make sure that trace can be opened
509 public void test3_12ImportCtfWithMetadataSelection() {
510 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
511 testSingleTrace(LTTNG_KERNEL_TRACE_METADATA
, ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
);
516 * Action : Recursive import with auto-detection (Rename All)
520 * Procedure : 1) Open Import wizard (see 3.1-3.2)
521 * 2) Browse to directory ${local}/traces/import
522 * 3) select directory import
523 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
525 * 6) When dialog appears select "Rename All"
528 * Expected Results: All Traces are imported with respective trace type set.
529 * Traces with name clashes are imported with suffix (2). 1 trace
530 * (unrecognized.log) is imported with trace type unknown. Make sure that
531 * traces can be opened which have a trace type set. The unknown trace type
532 * should open with the text editor.
535 public void test3_13ImportRecursiveAutoRenameAll() {
536 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
538 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
539 importTrace(optionFlags
, ImportConfirmation
.RENAME_ALL
, "");
541 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
542 String traceName
= info
.getTraceName();
543 if (CLASHING_TRACEINFOS
.contains(info
)) {
544 traceName
= toRenamedName(traceName
);
546 verifyTrace(info
, optionFlags
, traceName
);
549 // Also check unrecognized file
550 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
555 * Action : Recursive import with auto-detection (Overwrite All)
559 * Procedure : 1) Open Import wizard (see 3.1-3.2)
560 * 2) Browse to directory ${local}/traces/import/
561 * 3) select directory import
562 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
564 * 6) When dialog appears select Overwrite All"
567 * Expected Results: All Traces are imported with respective trace type set.
568 * Traces with name clashes are overwritten . 1 trace (unrecognized.log) is
569 * imported with trace type unknown. Make sure that traces can be opened
570 * which have a trace type set. The unknown trace type should open with the
574 public void test3_14ImportRecursiveAutoOverwriteAll() {
575 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
577 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
578 importTrace(optionFlags
, ImportConfirmation
.OVERWRITE_ALL
, "");
580 for (TestTraceInfo info
: CLASHING_TRACEINFOS
) {
581 verifyTrace(info
, optionFlags
);
584 // All traces should have clashed/overwritten (plus the unrecognized trace)
585 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
586 assertEquals(NUM_UNIQUE_TRACES
, tracesFolderItem
.getItems().length
);
588 // Also check unrecognized file
589 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
594 * Action : Recursive import with auto-detection (Skip All)
598 * Procedure : 1) Open Import wizard (see 3.1-3.2)
599 * 2) Browse to directory ${local}/traces/import/
600 * 3) select directory import
601 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning" and select "Create Links to workspace" and uncheck "preserve folder structure"
603 * 6) When dialog appears select Skip All"
606 * Expected Results: All Traces are imported with respective trace type set. Traces with name
607 * clashes are not imported. 1 trace (unrecognized.log) is imported with
608 * trace type unknown. The unknown trace type should open with the text
612 public void test3_15ImportRecursiveAutoSkipAll() {
613 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
615 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
616 importTrace(optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
618 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
619 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
620 if (!CLASHING_TRACEINFOS
.contains(info
)) {
621 verifyTrace(info
, optionFlags
);
625 // All traces should have skipped (plus the unrecognized trace)
626 assertEquals(NUM_UNIQUE_TRACES
, tracesFolderItem
.getItems().length
);
628 // Also check unrecognized file
629 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
634 * Action : Recursive import with auto-detection (test rename, overwrite and
639 * Procedure : 1) Open Import wizard (see 3.1-3.2)
640 * 2) Browse to directory ${local}/traces/import/
641 * 3) select directory import
642 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
644 * 6) When dialog appears select "Rename"
645 * 7) When dialog appears select "Overwrite"
646 * 8) When dialog appears select "Skip"
649 * Expected Results: All Traces are imported with respective trace type set. Traces with name
650 * clashes are either renamed, overwritten or skipped as per dialog action.
651 * Make sure that traces can be opened which have trace type set. The
652 * unknown trace type should open with the text editor.
655 public void test3_16ImportRecursiveAutoRenameOverwriteSkip() {
656 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
658 Supplier
<ImportConfirmation
> confirmationSupplier
= new Supplier
<ImportConfirmation
>() {
659 final ImportConfirmation dialogConfirmationOrder
[] = new ImportConfirmation
[] { ImportConfirmation
.RENAME
, ImportConfirmation
.OVERWRITE
, ImportConfirmation
.SKIP
};
663 public ImportConfirmation
get() {
664 if (fRsponseNum
>= dialogConfirmationOrder
.length
) {
668 ImportConfirmation confirmation
= dialogConfirmationOrder
[fRsponseNum
];
673 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
674 importTrace(optionFlags
, confirmationSupplier
, LTTNG_KERNEL_TRACE
.getTracePath(), CLASHES_LTTNG_KERNEL_TRACE
.getTracePath(), SIMPLE_SERVER1_UST_TRACE
.getTracePath(), CLASHES_SIMPLE_SERVER1_UST_TRACE
.getTracePath(),
675 SIMPLE_SERVER2_UST_TRACE
.getTracePath(), CLASHES_SIMPLE_SERVER2_UST_TRACE
.getTracePath(), UNRECOGNIZED_LOG
.getTracePath());
677 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
);
680 String renamed
= toRenamedName(CLASHES_LTTNG_KERNEL_TRACE
.getTraceName());
681 verifyTrace(CLASHES_LTTNG_KERNEL_TRACE
, optionFlags
, renamed
);
684 verifyTrace(CLASHES_SIMPLE_SERVER1_UST_TRACE
, optionFlags
);
687 verifyTrace(SIMPLE_SERVER2_UST_TRACE
, optionFlags
);
689 // Also check unrecognized file
690 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
695 * Action : Recursive import with specific trace type 1 (Skip All) skip)
699 * Procedure : 1) Open Import wizard
700 * 2) Browse to directory ${local}/traces/import/
701 * 3) Select directory import
702 * 4) Select trace type "Generic CTF Trace", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"and
704 * 6) When dialog appears select Skip All"
707 * Expected Results: After selecting trace type, verify that button "Import
708 * unrecognized traces" is disabled. 4 CTF traces are imported with trace
709 * type "Generic CTF Trace" . Make sure that these traces can be opened
712 public void test3_17ImportRecursiveSpecifyTraceTypeCTF() {
713 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
715 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
716 importTrace(GENERIC_CTF_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
718 final TestTraceInfo
[] CTF_TRACEINFOS
= new TestTraceInfo
[] {
720 SIMPLE_SERVER1_UST_TRACE
,
721 SIMPLE_SERVER2_UST_TRACE
,
722 UST_OVERLAP_TESTING_UST_TRACE
724 for (TestTraceInfo info
: CTF_TRACEINFOS
) {
725 verifyTrace(info
, optionFlags
, info
.getTraceName(), GENERIC_CTF_TRACE_TYPE
);
728 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
729 assertEquals(CTF_TRACEINFOS
.length
, tracesFolderItem
.getItems().length
);
734 * Action : Recursive import with specific trace type 2 (Skip All)
738 * Procedure : 1) Open Import wizard (see 3.1-3.2)
739 * 2) Browse to directory ${local}/traces/import/
740 * 3) Select directory import
741 * 4) Select trace type "LTTng Kernel Trace", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
743 * 6) When dialog appears select Skip All"
746 * Expected Results: After selecting trace type, verify that button "Import
747 * unrecognized traces" is disabled. One LTTng Kernel trace is imported with
748 * trace type "LTTng Kernel Trace". Make sure that this trace can be opened.
751 public void test3_18ImportRecursiveSpecifyTraceTypeKernel() {
752 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
754 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
755 importTrace(LTTNG_KERNEL_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
757 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
);
759 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
760 assertEquals(1, tracesFolderItem
.getItems().length
);
765 * Action : Recursive import with specific trace type 3 (Skip All)
769 * Procedure : 1) Open Import wizard
770 * 2) Browse to directory ${local}/traces/import/
771 * 3) Select directory import
772 * 4) Select trace type "LTTng UST Trace", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
774 * 6) When dialog appears select Skip All"
777 * Expected Results: After selecting trace type, verify that button "Import
778 * unrecognized traces" is disabled. 3 LTTng UST traces are imported with
779 * trace type "LTTng UST Trace". Make sure that these traces can be opened.
782 public void test3_19ImportRecursiveSpecifyTraceTypeUST() {
783 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
785 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
786 importTrace(LTTNG_UST_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
788 final TestTraceInfo
[] UST_TRACEINFOS
= new TestTraceInfo
[] {
789 SIMPLE_SERVER1_UST_TRACE
,
790 SIMPLE_SERVER2_UST_TRACE
,
791 UST_OVERLAP_TESTING_UST_TRACE
793 for (TestTraceInfo info
: UST_TRACEINFOS
) {
794 verifyTrace(info
, optionFlags
);
797 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
798 assertEquals(UST_TRACEINFOS
.length
, tracesFolderItem
.getItems().length
);
803 * Action : Recursive import with specific trace type 4 (Skip All)
807 * Procedure : 1) Open Import wizard (see 3.1-3.2)
808 * 2) Browse to directory ${local}/traces/import/
809 * 3) select directory import
810 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
812 * 6) When dialog appears select Skip All"
815 * Expected Results: All text files in directories are imported as trace and
816 * trace type "Tmf Generic" is set. Note that trace type validation only
817 * checks for file exists and that file is not a directory. Make sure that
818 * these traces can be opened. However traces with wrong trace type won't
819 * show any events in the table.
822 public void test3_20ImportRecursiveSpecifyTraceTypeCustomText() {
823 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
825 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
826 importTrace(CUSTOM_TEXT_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
827 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
);
829 final TestTraceInfo
[] TEXT_BASED_TRACEINFOS
= new TestTraceInfo
[] {
831 CUSTOM_XML_LOG_AS_TEXT
,
834 for (TestTraceInfo info
: TEXT_BASED_TRACEINFOS
) {
835 verifyTrace(info
, optionFlags
, info
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
838 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
839 assertEquals(TEXT_BASED_TRACEINFOS
.length
, tracesFolderItem
.getItems().length
);
842 private static void verifyTrace(TestTraceInfo traceInfo
, int importOptionFlags
) {
843 verifyTrace(traceInfo
, importOptionFlags
, traceInfo
.getTraceName());
848 * Action : Recursive import with preserved folder structure
852 * Procedure : 0) Delete all traces in project
853 * 1) Open Import wizard
854 * 2) Browse to directory ${local}/traces/import/
855 * 3) Select directory import
856 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and select "Preserve Folder Structure"
860 * Expected Results: All matching traces are imported with trace type set.
861 * The folder "clashes" is imported with traces inside. Make sure that the
862 * traces can be opened.
865 public void test3_29ImportRecursivePreserve() {
866 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
868 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
869 importTrace(CUSTOM_TEXT_TRACE_TYPE
, optionFlags
, ImportConfirmation
.CONTINUE
, "");
871 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
, CUSTOM_TEXT_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
872 verifyTrace(CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, CUSTOM_XML_LOG_AS_TEXT
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
873 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
, UNRECOGNIZED_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
874 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, CLASHES_CUSTOM_TEXT_LOG
.getTracePath(), CUSTOM_TEXT_TRACE_TYPE
);
875 verifyTrace(CLASHES_CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, CLASHES_CUSTOM_XML_LOG_AS_TEXT
.getTracePath(), CUSTOM_TEXT_TRACE_TYPE
);
877 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
878 assertEquals(4, tracesFolderItem
.getItems().length
);
879 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
880 assertEquals(2, clashesFolderItem
.getItems().length
);
885 * Action : Recursive import with preserved folder structure (Skip All)
889 * Procedure : 1) Open Import wizard
890 * 2) Browse to directory ${local}/traces/import/
891 * 3) Select directory import
892 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and select "Preserve Folder Structure"
894 * 6) When dialog appears select "Skip All"
897 * Expected Results: The wizard should finish quickly as no trace will be
898 * imported. Make sure that the traces can be opened.
901 public void test3_30ImportRecursivePreserveSkipAll() {
902 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
903 importTrace(CUSTOM_TEXT_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
905 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
, CUSTOM_TEXT_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
906 verifyTrace(CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, CUSTOM_XML_LOG_AS_TEXT
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
907 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
, UNRECOGNIZED_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
908 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, CLASHES_CUSTOM_TEXT_LOG
.getTracePath(), CUSTOM_TEXT_TRACE_TYPE
);
909 verifyTrace(CLASHES_CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, CLASHES_CUSTOM_XML_LOG_AS_TEXT
.getTracePath(), CUSTOM_TEXT_TRACE_TYPE
);
911 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
912 assertEquals(4, tracesFolderItem
.getItems().length
);
913 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
914 assertEquals(2, clashesFolderItem
.getItems().length
);
915 //TOOD: verify that traces were actually skipped
920 * Action : Recursive import with preserved folder structure (Rename All)
924 * Procedure : 1) Open Import wizard
925 * 2) Browse to directory ${local}/traces/import/
926 * 3) Select directory import
927 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and select "Preserve Folder Structure"
929 * 6) When dialog appears select "Rename All"
932 * Expected Results: All matching traces are imported with trace type set.
933 * The traces are renamed with suffix (2). The folder "clashes" is imported
934 * with traces inside. Make sure that the traces can be opened.
937 public void test3_31ImportRecursivePreserveRenameAll() {
938 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
939 importTrace(CUSTOM_TEXT_TRACE_TYPE
, optionFlags
, ImportConfirmation
.RENAME_ALL
, "");
941 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
, toRenamedName(CUSTOM_TEXT_LOG
.getTraceName()), CUSTOM_TEXT_TRACE_TYPE
);
942 verifyTrace(CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, toRenamedName(CUSTOM_XML_LOG_AS_TEXT
.getTraceName()), CUSTOM_TEXT_TRACE_TYPE
);
943 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
, toRenamedName(UNRECOGNIZED_LOG
.getTraceName()), CUSTOM_TEXT_TRACE_TYPE
);
944 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, toRenamedName(CLASHES_CUSTOM_TEXT_LOG
.getTracePath()), CUSTOM_TEXT_TRACE_TYPE
);
945 verifyTrace(CLASHES_CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, toRenamedName(CLASHES_CUSTOM_XML_LOG_AS_TEXT
.getTracePath()), CUSTOM_TEXT_TRACE_TYPE
);
947 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
948 assertEquals(7, tracesFolderItem
.getItems().length
);
949 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
950 assertEquals(4, clashesFolderItem
.getItems().length
);
955 * Action : Import from zip archive with preserved folder structure
959 * Procedure : 0) Delete all traces in project
960 * 1) Open Import wizard
961 * 2) Select archive file: traces.zip
962 * 3) Select archive root directory
963 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
967 * Expected Results: All traces are imported with trace type set. The folder
968 * "clashes" is imported with traces inside. Make sure that the traces can
972 public void test3_36ImportZipArchivePreserve() {
973 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
975 int optionFlags
= ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
976 importTrace("traces.zip", null, optionFlags
, ImportConfirmation
.CONTINUE
, "");
978 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
979 verifyTrace(info
, optionFlags
, info
.getTracePath());
982 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
983 assertEquals(7, tracesFolderItem
.getItems().length
);
984 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
985 assertEquals(6, clashesFolderItem
.getItems().length
);
990 * Action : Import from zip archive without preserved folder structure
995 * Procedure : 0) Delete all traces in project
996 * 1) Open Import wizard
997 * 2) Select archive file: traces.zip
998 * 3) Select archive root directory
999 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and unselect "Preserve Folder Structure"
1001 * 6) When dialog appears select "Rename All"
1004 * Expected Results: All traces are imported with trace type set. The traces
1005 * from folder "clashes" are renamed with suffix (2). Make sure that the
1006 * traces can be opened.
1009 public void test3_37ImportZipArchiveNoPreserve() {
1010 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1012 int optionFlags
= 0;
1013 importTrace("traces.zip", null, optionFlags
, ImportConfirmation
.RENAME_ALL
, "");
1015 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
1016 String traceName
= info
.getTraceName();
1017 if (CLASHING_TRACEINFOS
.contains(info
)) {
1018 traceName
= toRenamedName(traceName
);
1020 verifyTrace(info
, optionFlags
, traceName
);
1023 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1024 assertEquals(12, tracesFolderItem
.getItems().length
);
1029 * Action : Import from zip archive specific traces
1033 * Procedure : 0) Delete all traces in project
1034 * 1) Open Import wizard
1035 * 2) Select archive file: traces.zip
1036 * 3) Select file z-clashes/ExampleCustomTxt.log and directory kernel-overlap-testing/
1037 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
1041 * Expected Results: The specified traces are imported with trace type set.
1042 * Make sure that the traces can be opened.
1045 public void test3_38ImportZipArchiveSpecificTraces() {
1046 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1048 int optionFlags
= ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
1049 importTrace("traces.zip", null, optionFlags
, ImportConfirmation
.CONTINUE
, "z-clashes/ExampleCustomTxt.log", "kernel-overlap-testing/");
1051 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, CLASHES_CUSTOM_TEXT_LOG
.getTracePath());
1052 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
, LTTNG_KERNEL_TRACE
.getTracePath());
1054 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1055 assertEquals(2, tracesFolderItem
.getItems().length
);
1056 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
1057 assertEquals(1, clashesFolderItem
.getItems().length
);
1062 * Action : Import from tar.gz archive with preserved folder structure
1066 * Procedure : 0) Delete all traces in project
1067 * 1) Open Import wizard
1068 * 2) Select archive file: traces.tar.gz
1069 * 3) Select archive root directory
1070 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
1074 * Expected Results: All traces are imported with trace type set. The folder
1075 * "clashes" is imported with traces inside. Make sure that the traces can
1079 public void test3_39ImportTarGzipArchivePreserve() {
1080 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1082 int optionFlags
= ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
1083 importTrace("traces.tar.gz", null, optionFlags
, ImportConfirmation
.CONTINUE
, "");
1085 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
1086 verifyTrace(info
, optionFlags
, info
.getTracePath());
1089 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1090 assertEquals(7, tracesFolderItem
.getItems().length
);
1091 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
1092 assertEquals(6, clashesFolderItem
.getItems().length
);
1097 * Action : Import from tar.gz archive without preserved folder structure (Rename All)
1101 * Procedure : 0) Delete all traces in project
1102 * 1) Open Import wizard
1103 * 2) Select archive file: traces.tar.gz
1104 * 3) Select archive root directory
1105 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and unselect "Preserve Folder Structure"
1107 * 6) When dialog appears select "Rename All"
1110 * Expected Results: All traces are imported with trace type set. The traces
1111 * from folder "clashes" are renamed with suffix (2). Make sure that the
1112 * traces can be opened.
1115 public void test3_40ImportTarGzipArchiveNoPreserve() {
1116 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1118 int optionFlags
= 0;
1119 importTrace("traces.tar.gz", null, optionFlags
, ImportConfirmation
.RENAME_ALL
, "");
1121 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
1122 String traceName
= info
.getTraceName();
1123 if (CLASHING_TRACEINFOS
.contains(info
)) {
1124 traceName
= toRenamedName(traceName
);
1126 verifyTrace(info
, optionFlags
, traceName
);
1129 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1130 assertEquals(12, tracesFolderItem
.getItems().length
);
1135 * Action : Import from tar.gz archive specific traces
1139 * Procedure : 0) Delete all traces in project
1140 * 1) Open Import wizard
1141 * 2) Select archive file: traces.tar.gz
1142 * 3) Select file z-clashes/ExampleCustomTxt.log and directory kernel-overlap-testing/
1143 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
1147 * Expected Results: The specified traces are imported with trace type set.
1148 * Make sure that the traces can be opened.
1151 public void test3_41ImportTarGzipArchiveSpecificTraces() {
1152 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1154 int optionFlags
= ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
1155 importTrace("traces.tar.gz", null, optionFlags
, ImportConfirmation
.CONTINUE
, "z-clashes/ExampleCustomTxt.log", "kernel-overlap-testing/");
1157 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, CLASHES_CUSTOM_TEXT_LOG
.getTracePath());
1158 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
, LTTNG_KERNEL_TRACE
.getTracePath());
1160 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1161 assertEquals(2, tracesFolderItem
.getItems().length
);
1162 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
1163 assertEquals(1, clashesFolderItem
.getItems().length
);
1166 private static void verifyTrace(TestTraceInfo traceInfo
, int importOptionFlags
, String traceName
) {
1167 verifyTrace(traceInfo
, importOptionFlags
, traceName
, traceInfo
.getTraceType());
1170 private static void verifyTrace(TestTraceInfo traceInfo
, int importOptionFlags
, String traceName
, String traceType
) {
1171 String
[] tracePath
= new Path(traceName
).segments();
1172 SWTBotTreeItem traceItem
= SWTBotUtils
.getTraceProjectItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
), tracePath
);
1173 checkTraceType(traceItem
, traceType
);
1174 openTrace(traceItem
);
1175 if (traceType
!= null && !traceType
.isEmpty()) {
1176 SWTBotImportWizardUtils
.testEventsTable(fBot
, traceName
, traceInfo
.getNbEvents(), traceInfo
.getFirstEventTimestamp());
1178 // If there is no trace type, make sure it can be opened with the text editor
1179 fBot
.waitUntil(ConditionHelpers
.isEditorOpened(fBot
, traceName
));
1180 SWTBotEditor editor
= fBot
.editorByTitle(traceName
);
1181 assertEquals(TEXT_EDITOR_ID
, editor
.getReference().getId());
1183 checkTraceLinked(traceItem
, (importOptionFlags
& ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
) != 0);
1186 private static String
toRenamedName(String traceName
) {
1187 return traceName
+ "(2)";
1190 private static void openTrace(SWTBotTreeItem traceItem
) {
1192 traceItem
.doubleClick();
1195 private static void testSingleTrace(TestTraceInfo traceInfo
, int optionFlags
) {
1196 importTrace(optionFlags
, traceInfo
.getTracePath());
1197 verifyTrace(traceInfo
, optionFlags
);
1200 private static void importTrace(int optionFlags
, String
... tracePaths
) {
1201 importTrace(optionFlags
, ImportConfirmation
.CONTINUE
, tracePaths
);
1204 private static void importTrace(int optionFlags
, ImportConfirmation confirmationMode
, String
... tracePaths
) {
1205 importTrace(null, optionFlags
, confirmationMode
, tracePaths
);
1208 private static void importTrace(String traceType
, int optionFlags
, ImportConfirmation confirmationMode
, String
... tracePaths
) {
1209 importTrace(null, traceType
, optionFlags
, confirmationMode
, tracePaths
);
1212 private static void importTrace(String archiveFile
, String traceType
, int optionFlags
, ImportConfirmation confirmationMode
, String
... tracePaths
) {
1213 importTrace(archiveFile
, traceType
, optionFlags
, new Supplier
<ImportConfirmation
>() {
1214 boolean fDone
= false;
1216 public ImportConfirmation
get() {
1221 return confirmationMode
;
1226 private static void importTrace(int optionFlags
, Supplier
<ImportConfirmation
> confirmationSuplier
, String
... tracePaths
) {
1227 importTrace(null, null, optionFlags
, confirmationSuplier
, tracePaths
);
1231 * @param tracePaths relative to parent test traces folder
1233 private static void importTrace(String archiveFile
, String traceType
, int optionFlags
, Supplier
<ImportConfirmation
> confirmationSuplier
, String
... tracePaths
) {
1234 SWTBotTreeItem traceFolder
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1236 SWTBotShell shell
= openTraceFoldersImport(traceFolder
);
1237 SWTBot bot
= shell
.bot();
1238 String rootFolderName
;
1239 if (archiveFile
== null) {
1240 rootFolderName
= "import";
1241 String importDirectoryFullPath
= getPath(rootFolderName
);
1242 SWTBotImportWizardUtils
.selectImportFromDirectory(bot
, importDirectoryFullPath
);
1244 rootFolderName
= "/";
1245 String importArchiveFullPath
= getPath("archives" + File
.separator
+ archiveFile
);
1246 SWTBotImportWizardUtils
.selectImportFromArchive(bot
, importArchiveFullPath
);
1249 for (String tracePath
: tracePaths
) {
1250 IPath somePath
= new Path(rootFolderName
).append(tracePath
);
1251 String
[] treePath
= somePath
.segments();
1252 if (archiveFile
!= null) {
1253 String
[] newPath
= new String
[treePath
.length
+ 1];
1255 System
.arraycopy(treePath
, 0, newPath
, 1, treePath
.length
);
1258 SWTBotImportWizardUtils
.selectItem(fBot
, treePath
);
1261 SWTBotImportWizardUtils
.setOptions(bot
, optionFlags
, traceType
);
1262 bot
.button("Finish").click();
1264 ImportConfirmation importConfirmation
= confirmationSuplier
.get();
1265 while (importConfirmation
!= null) {
1266 if (importConfirmation
!= ImportConfirmation
.CONTINUE
) {
1267 fBot
.waitUntil(Conditions
.shellIsActive("Confirmation"));
1268 SWTBotShell shell2
= fBot
.activeShell();
1269 SWTBotButton button
= shell2
.bot().button(importConfirmation
.getInName());
1272 importConfirmation
= confirmationSuplier
.get();
1275 fBot
.waitUntil(Conditions
.shellCloses(shell
));
1278 private static void checkTraceType(SWTBotTreeItem traceItem
, String traceType
) {
1279 assertEquals(traceType
, getTraceProperty(traceItem
, "type"));
1282 private static void checkTraceLinked(SWTBotTreeItem traceItem
, boolean linked
) {
1283 assertEquals(Boolean
.toString(linked
), getTraceProperty(traceItem
, "linked"));
1286 private static String
getTraceProperty(SWTBotTreeItem traceItem
, String property
) {
1287 SWTBotUtils
.openView(IPageLayout
.ID_PROP_SHEET
);
1288 SWTBotView view
= fBot
.viewById(IPageLayout
.ID_PROP_SHEET
);
1291 SWTBotTreeItem traceTypeItem
= SWTBotUtils
.getTreeItem(view
.bot(), view
.bot().tree(), "Resource properties", property
);
1292 return traceTypeItem
.cell(1);
1295 private static SWTBotShell
openTraceFoldersImport(SWTBotTreeItem traceItem
) {
1296 traceItem
.contextMenu().menu("Import...").click();
1297 fBot
.waitUntil(Conditions
.shellIsActive("Trace Import"));
1299 SWTBotShell shell
= fBot
.shell("Trace Import");