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
.AfterClass
;
47 import org
.junit
.BeforeClass
;
48 import org
.junit
.FixMethodOrder
;
49 import org
.junit
.Test
;
50 import org
.junit
.runner
.RunWith
;
51 import org
.junit
.runners
.MethodSorters
;
53 import com
.google
.common
.collect
.ImmutableList
;
54 import com
.google
.common
.collect
.ImmutableSet
;
57 * SWTBot test for testing Project Explorer trace folders (context-menu,
60 @RunWith(SWTBotJunit4ClassRunner
.class)
61 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
62 @SuppressWarnings({"restriction", "javadoc"})
63 public class ProjectExplorerTracesFolderTest
{
65 private static final String PROP_LAST_MODIFIED_PROPERTY
= "last modified";
66 private static final String TEXT_EDITOR_ID
= "org.eclipse.ui.DefaultTextEditor";
68 private static final String GENERIC_CTF_TRACE_TYPE
= "Common Trace Format : Generic CTF Trace";
69 private static final String LTTNG_KERNEL_TRACE_TYPE
= "Common Trace Format : Linux Kernel Trace";
70 private static final String LTTNG_UST_TRACE_TYPE
= "Common Trace Format : LTTng UST Trace";
71 private static final String CUSTOM_TEXT_TRACE_TYPE
= "Custom Text : TmfGeneric";
72 private static final String CUSTOM_XML_TRACE_TYPE
= "Custom XML : Custom XML Log";
74 private static final @NonNull TestTraceInfo CUSTOM_TEXT_LOG
= new TestTraceInfo("ExampleCustomTxt.log", CUSTOM_TEXT_TRACE_TYPE
, 10, "29:52.034");
75 private static final @NonNull TestTraceInfo CUSTOM_XML_LOG
= new TestTraceInfo("ExampleCustomXml.xml", CUSTOM_XML_TRACE_TYPE
, 6, "22:01:20");
76 private static final @NonNull TestTraceInfo LTTNG_KERNEL_TRACE
= new TestTraceInfo("kernel-overlap-testing", LTTNG_KERNEL_TRACE_TYPE
, 1000, "04:32.650 993 664");
77 private static final @NonNull TestTraceInfo SIMPLE_SERVER1_UST_TRACE
= new TestTraceInfo("simple_server-thread1", LTTNG_UST_TRACE_TYPE
, 1000, "04:32.650 993 664");
78 private static final @NonNull TestTraceInfo SIMPLE_SERVER2_UST_TRACE
= new TestTraceInfo("simple_server-thread2", LTTNG_UST_TRACE_TYPE
, 1000, "04:32.650 993 664");
79 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");
81 private static final String CLASHES_DIR_NAME
= "z-clashes";
82 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");
83 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");
84 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");
85 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");
86 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");
87 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");
90 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(),
91 LTTNG_KERNEL_TRACE
.getFirstEventTimestamp());
92 private static final @NonNull TestTraceInfo UNRECOGNIZED_LOG
= new TestTraceInfo("unrecognized.log", "", 0, "");
93 private static final @NonNull TestTraceInfo CUSTOM_XML_LOG_AS_TEXT
= new TestTraceInfo("ExampleCustomXml.xml", CUSTOM_TEXT_TRACE_TYPE
, 0, "");
94 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, "");
96 private static final TestTraceInfo
[] ALL_TRACEINFOS
= new TestTraceInfo
[] {
100 SIMPLE_SERVER1_UST_TRACE
,
101 SIMPLE_SERVER2_UST_TRACE
,
102 UST_OVERLAP_TESTING_UST_TRACE
,
104 CLASHES_CUSTOM_TEXT_LOG
,
105 CLASHES_CUSTOM_XML_LOG
,
106 CLASHES_LTTNG_KERNEL_TRACE
,
107 CLASHES_SIMPLE_SERVER1_UST_TRACE
,
108 CLASHES_SIMPLE_SERVER2_UST_TRACE
,
109 CLASHES_UST_OVERLAP_TESTING_UST_TRACE
112 private static final Set
<TestTraceInfo
> CLASHING_TRACEINFOS
= ImmutableSet
.of(
113 CLASHES_CUSTOM_TEXT_LOG
,
114 CLASHES_CUSTOM_XML_LOG
,
115 CLASHES_LTTNG_KERNEL_TRACE
,
116 CLASHES_SIMPLE_SERVER1_UST_TRACE
,
117 CLASHES_SIMPLE_SERVER2_UST_TRACE
,
118 CLASHES_UST_OVERLAP_TESTING_UST_TRACE
);
120 // All normal traces plus the unrecognized trace
121 private static final int NUM_UNIQUE_TRACES
= CLASHING_TRACEINFOS
.size() + 1;
124 private static final File TEST_TRACES_PATH
= new File(new Path(TmfTraceManager
.getTemporaryDirPath()).append("testtraces").toOSString());
125 private static final String TRACE_PROJECT_NAME
= "test";
126 private static final String MANAGE_CUSTOM_PARSERS_SHELL_TITLE
= "Manage Custom Parsers";
128 private static SWTWorkbenchBot fBot
;
130 /** The Log4j logger instance. */
131 private static final Logger fLogger
= Logger
.getRootLogger();
133 private static String
getPath(String relativePath
) {
134 return new Path(TEST_TRACES_PATH
.getAbsolutePath()).append(relativePath
).toOSString();
140 * @throws IOException
143 public static void init() throws IOException
{
144 TestDirectoryStructureUtil
.generateTraceStructure(TEST_TRACES_PATH
);
146 SWTBotUtils
.initialize();
148 /* Set up for swtbot */
149 SWTBotPreferences
.TIMEOUT
= 20000; /* 20 second timeout */
150 SWTBotPreferences
.KEYBOARD_LAYOUT
= "EN_US";
151 fLogger
.removeAllAppenders();
152 fLogger
.addAppender(new NullAppender());
153 fBot
= new SWTWorkbenchBot();
155 SWTBotUtils
.closeView("Welcome", fBot
);
157 SWTBotUtils
.switchToTracingPerspective();
159 /* Finish waiting for eclipse to load */
160 WaitUtils
.waitForJobs();
161 SWTBotUtils
.createProject(TRACE_PROJECT_NAME
);
165 * Test class tear down method.
168 public static void tearDown() {
169 SWTBotUtils
.deleteProject(TRACE_PROJECT_NAME
, fBot
);
170 fLogger
.removeAllAppenders();
173 private static void test3_01Preparation() {
174 // 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
175 CustomTxtTraceDefinition
[] txtDefinitions
= CustomTxtTraceDefinition
.loadAll(getPath("customParsers/ExampleCustomTxtParser.xml"));
176 txtDefinitions
[0].save();
177 CustomXmlTraceDefinition
[] xmlDefinitions
= CustomXmlTraceDefinition
.loadAll(getPath("customParsers/ExampleCustomXmlParser.xml"));
178 xmlDefinitions
[0].save();
180 SWTBotTreeItem traceFolder
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
181 traceFolder
.contextMenu("Manage Custom Parsers...").click();
182 fBot
.waitUntil(Conditions
.shellIsActive(MANAGE_CUSTOM_PARSERS_SHELL_TITLE
));
183 SWTBotShell shell
= fBot
.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE
);
184 SWTBot shellBot
= shell
.bot();
186 // Make sure the custom text trace type is imported
187 shellBot
.list().select(CUSTOM_TEXT_LOG
.getTraceType());
189 // Make sure the custom xml trace type is imported
190 shellBot
.radio("XML").click();
191 shellBot
.list().select(CUSTOM_XML_LOG
.getTraceType());
192 shellBot
.button("Close").click();
193 shellBot
.waitUntil(Conditions
.shellCloses(shell
));
197 * Test that the expected context menu items are there
199 * Action : Trace Folder menu
201 * Procedure :Select the Traces folder and open its context menu
203 * Expected Results: Correct menu opens (Import, Refresh, etc)
206 public void test3_01ContextMenuPresence() {
207 test3_01Preparation();
209 SWTBotTreeItem traceItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
211 final List
<String
> EXPECTED_MENU_LABELS
= ImmutableList
.of(
219 "Import Trace Package...",
220 "Fetch Remote Traces...",
222 "Export Trace Package...",
224 "Manage Custom Parsers...",
225 "Manage XML analyses...",
227 "Apply Time Offset...",
232 List
<String
> menuLabels
= traceItem
.contextMenu().menuItems();
233 for (int i
= 0; i
< menuLabels
.size(); i
++) {
234 assertEquals(EXPECTED_MENU_LABELS
.get(i
), menuLabels
.get(i
));
237 fBot
.closeAllEditors();
241 * Test that the trace import wizard appears
243 * Action : Trace Import Wizard
245 * Procedure : Select Import
247 * Expected Results: Trace Import Wizard appears
250 public void test3_02Import() {
251 SWTBotTreeItem traceItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
253 SWTBotShell shell
= openTraceFoldersImport(traceItem
);
254 shell
.bot().button("Cancel").click();
258 * Test that the trace import wizard can import a single custom text trace
260 * Action : Import single custom text trace (link to workspace)
263 * Procedure : 1) Browse to directory ${local}/traces/import/
264 * 2) Select trace ExampleCustomTxt.log
265 * 3) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning" and select "Create Links to workspace" and
269 * Expected Results: Imported trace appear in Traces Folder and the Trace Type Tmf Generic is set. Make sure trace can be opened
272 public void test3_03SingleCustomTextTrace() {
273 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
274 testSingleTrace(CUSTOM_TEXT_LOG
, optionFlags
);
279 * Action : Import Single custom XML trace (link to workspace)
283 * Procedure : redo 3.1-3.3 but this time select ExampleCustomXml.xml
286 * Expected Results: Imported trace appear in Traces Folder and the Trace
287 * Type "Custom XML log" is set. Make sure that trace can be opened
290 public void test3_04SingleCustomXmlTrace() {
291 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
292 testSingleTrace(CUSTOM_XML_LOG
, optionFlags
);
297 * Action : Import LTTng Kernel CTF trace (link to workspace)
301 * Procedure : redo 3.1-3.3 but this time select directory kernel-overlap-testing/
304 * Expected Results: Imported trace appear in Traces Folder and the Trace
305 * Type "LTTng Kernel" is set. Make sure that trace can be opened
308 public void test3_05SingleCtfTrace() {
309 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
310 testSingleTrace(LTTNG_KERNEL_TRACE
, optionFlags
);
315 * Action : Rename + copy import
319 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace"
320 * 2) When dialog box appear select Rename
323 * Expected Results: Traces are imported with new name that has a suffix (2)
324 * at the end. Make sure that imported traces are copied to the project.
327 public void test3_06RenameCopyImport() {
328 testRenameCopyImport(CUSTOM_TEXT_LOG
);
329 testRenameCopyImport(CUSTOM_XML_LOG
);
330 testRenameCopyImport(LTTNG_KERNEL_TRACE
);
333 private static void testRenameCopyImport(TestTraceInfo traceInfo
) {
334 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
;
335 importTrace(optionFlags
, ImportConfirmation
.RENAME
, traceInfo
.getTraceName());
336 String renamed
= toRenamedName(traceInfo
.getTraceName());
337 verifyTrace(traceInfo
, optionFlags
, renamed
);
342 * Action : Overwrite + copy import
346 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace"
347 * 2) When dialog box appear select Overwrite
350 * Expected Results: Existing traces are deleted and new traces are
351 * imported. Make sure that imported traces are copied to the project and
355 public void test3_07OverwriteCopyImport() {
356 testOverwriteCopyImport(CUSTOM_TEXT_LOG
);
357 testOverwriteCopyImport(CUSTOM_XML_LOG
);
358 testOverwriteCopyImport(LTTNG_KERNEL_TRACE
);
361 private static void testOverwriteCopyImport(TestTraceInfo traceInfo
) {
362 String traceName
= traceInfo
.getTraceName();
363 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
), traceName
);
364 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
365 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
;
366 importTrace(optionFlags
, ImportConfirmation
.OVERWRITE
, traceName
);
367 verifyTrace(traceInfo
, optionFlags
);
369 assertNotEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
378 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace"
379 * 2) When dialog box appear select Skip
382 * Expected Results: Make sure that no new trace is imported
385 public void test3_08SkipImport() {
386 testSkipImport(CUSTOM_TEXT_LOG
);
387 testSkipImport(CUSTOM_XML_LOG
);
388 testSkipImport(LTTNG_KERNEL_TRACE
);
391 private static void testSkipImport(TestTraceInfo traceInfo
) {
392 String traceName
= traceInfo
.getTraceName();
393 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
), traceName
);
394 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
395 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
;
396 importTrace(optionFlags
, ImportConfirmation
.SKIP
, traceName
);
397 verifyTrace(traceInfo
, optionFlags
);
399 assertEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
404 * Action : Default overwrite
408 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace" and select "Overwrite existing without warning"
411 * Expected Results: Make sure that no dialog box appears (for renaming,
412 * overwriting, skipping) and existing traces are overwritten). Make sure
413 * trace can be opened
416 public void test3_09OverwriteOptionImport() {
417 testOverwriteOptionImport(CUSTOM_TEXT_LOG
);
418 testOverwriteOptionImport(CUSTOM_XML_LOG
);
419 testOverwriteOptionImport(LTTNG_KERNEL_TRACE
);
422 private static void testOverwriteOptionImport(TestTraceInfo traceInfo
) {
423 String traceName
= traceInfo
.getTraceName();
424 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
), traceName
);
425 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
427 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
;
428 importTrace(optionFlags
, ImportConfirmation
.CONTINUE
, traceName
);
429 verifyTrace(traceInfo
, optionFlags
);
431 assertNotEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
436 * Action : Import unrecognized
440 * Procedure : 1) Open Import wizard (see 3.1-3.2)
441 * 2) Browse to directory ${local}/traces/import
442 * 3) Select trace unrecognized.log
443 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning" and select "Create Links to workspace" and
447 * Expected Results: unrecognized.log is imported with trace type unknown.
448 * The default text file icon is displayed. The trace, when opened, is
449 * displayed in the text editor.
452 public void test3_10ImportUnrecognized() {
453 String traceName
= UNRECOGNIZED_LOG
.getTraceName();
454 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
455 importTrace(optionFlags
, traceName
);
456 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
461 * Action : Import unrecognized (ignore)
465 * Procedure : 1) redo 3.10, however unselect "Import unrecognized traces"
468 * Expected Results: unrecognized.log is not imported
471 public void test3_11ImportUnrecognizedIgnore() {
472 String traceName
= UNRECOGNIZED_LOG
.getTraceName();
473 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
474 int numTraces
= tracesFolderItem
.getItems().length
;
476 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, tracesFolderItem
, traceName
);
477 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
479 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
480 importTrace(optionFlags
, traceName
);
481 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
483 assertEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
484 assertEquals(numTraces
, tracesFolderItem
.getItems().length
);
489 * Action : Import CTF trace by selection metadata file only
493 * Procedure : 1) Redo 3.5, However only select metadata file instead of directory trace
496 * Expected Results: Imported trace appear in Traces Folder and the Trace
497 * Type "LTTng Kernel" is set. Make sure that trace can be opened
500 public void test3_12ImportCtfWithMetadataSelection() {
501 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
502 testSingleTrace(LTTNG_KERNEL_TRACE_METADATA
, ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
);
507 * Action : Recursive import with auto-detection (Rename All)
511 * Procedure : 1) Open Import wizard (see 3.1-3.2)
512 * 2) Browse to directory ${local}/traces/import
513 * 3) select directory import
514 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
516 * 6) When dialog appears select "Rename All"
519 * Expected Results: All Traces are imported with respective trace type set.
520 * Traces with name clashes are imported with suffix (2). 1 trace
521 * (unrecognized.log) is imported with trace type unknown. Make sure that
522 * traces can be opened which have a trace type set. The unknown trace type
523 * should open with the text editor.
526 public void test3_13ImportRecursiveAutoRenameAll() {
527 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
529 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
530 importTrace(optionFlags
, ImportConfirmation
.RENAME_ALL
, "");
532 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
533 String traceName
= info
.getTraceName();
534 if (CLASHING_TRACEINFOS
.contains(info
)) {
535 traceName
= toRenamedName(traceName
);
537 verifyTrace(info
, optionFlags
, traceName
);
540 // Also check unrecognized file
541 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
546 * Action : Recursive import with auto-detection (Overwrite All)
550 * Procedure : 1) Open Import wizard (see 3.1-3.2)
551 * 2) Browse to directory ${local}/traces/import/
552 * 3) select directory import
553 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
555 * 6) When dialog appears select Overwrite All"
558 * Expected Results: All Traces are imported with respective trace type set.
559 * Traces with name clashes are overwritten . 1 trace (unrecognized.log) is
560 * imported with trace type unknown. Make sure that traces can be opened
561 * which have a trace type set. The unknown trace type should open with the
565 public void test3_14ImportRecursiveAutoOverwriteAll() {
566 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
568 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
569 importTrace(optionFlags
, ImportConfirmation
.OVERWRITE_ALL
, "");
571 for (TestTraceInfo info
: CLASHING_TRACEINFOS
) {
572 verifyTrace(info
, optionFlags
);
575 // All traces should have clashed/overwritten (plus the unrecognized trace)
576 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
577 assertEquals(NUM_UNIQUE_TRACES
, tracesFolderItem
.getItems().length
);
579 // Also check unrecognized file
580 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
585 * Action : Recursive import with auto-detection (Skip All)
589 * Procedure : 1) Open Import wizard (see 3.1-3.2)
590 * 2) Browse to directory ${local}/traces/import/
591 * 3) select directory import
592 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning" and select "Create Links to workspace" and uncheck "preserve folder structure"
594 * 6) When dialog appears select Skip All"
597 * Expected Results: All Traces are imported with respective trace type set. Traces with name
598 * clashes are not imported. 1 trace (unrecognized.log) is imported with
599 * trace type unknown. The unknown trace type should open with the text
603 public void test3_15ImportRecursiveAutoSkipAll() {
604 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
606 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
607 importTrace(optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
609 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
610 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
611 if (!CLASHING_TRACEINFOS
.contains(info
)) {
612 verifyTrace(info
, optionFlags
);
616 // All traces should have skipped (plus the unrecognized trace)
617 assertEquals(NUM_UNIQUE_TRACES
, tracesFolderItem
.getItems().length
);
619 // Also check unrecognized file
620 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
625 * Action : Recursive import with auto-detection (test rename, overwrite and
630 * Procedure : 1) Open Import wizard (see 3.1-3.2)
631 * 2) Browse to directory ${local}/traces/import/
632 * 3) select directory import
633 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
635 * 6) When dialog appears select "Rename"
636 * 7) When dialog appears select "Overwrite"
637 * 8) When dialog appears select "Skip"
640 * Expected Results: All Traces are imported with respective trace type set. Traces with name
641 * clashes are either renamed, overwritten or skipped as per dialog action.
642 * Make sure that traces can be opened which have trace type set. The
643 * unknown trace type should open with the text editor.
646 public void test3_16ImportRecursiveAutoRenameOverwriteSkip() {
647 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
649 Supplier
<ImportConfirmation
> confirmationSupplier
= new Supplier
<ImportConfirmation
>() {
650 final ImportConfirmation dialogConfirmationOrder
[] = new ImportConfirmation
[] { ImportConfirmation
.RENAME
, ImportConfirmation
.OVERWRITE
, ImportConfirmation
.SKIP
};
654 public ImportConfirmation
get() {
655 if (fRsponseNum
>= dialogConfirmationOrder
.length
) {
659 ImportConfirmation confirmation
= dialogConfirmationOrder
[fRsponseNum
];
664 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
665 importTrace(optionFlags
, confirmationSupplier
, LTTNG_KERNEL_TRACE
.getTracePath(), CLASHES_LTTNG_KERNEL_TRACE
.getTracePath(), SIMPLE_SERVER1_UST_TRACE
.getTracePath(), CLASHES_SIMPLE_SERVER1_UST_TRACE
.getTracePath(),
666 SIMPLE_SERVER2_UST_TRACE
.getTracePath(), CLASHES_SIMPLE_SERVER2_UST_TRACE
.getTracePath(), UNRECOGNIZED_LOG
.getTracePath());
668 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
);
671 String renamed
= toRenamedName(CLASHES_LTTNG_KERNEL_TRACE
.getTraceName());
672 verifyTrace(CLASHES_LTTNG_KERNEL_TRACE
, optionFlags
, renamed
);
675 verifyTrace(CLASHES_SIMPLE_SERVER1_UST_TRACE
, optionFlags
);
678 verifyTrace(SIMPLE_SERVER2_UST_TRACE
, optionFlags
);
680 // Also check unrecognized file
681 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
686 * Action : Recursive import with specific trace type 1 (Skip All) skip)
690 * Procedure : 1) Open Import wizard
691 * 2) Browse to directory ${local}/traces/import/
692 * 3) Select directory import
693 * 4) Select trace type "Generic CTF Trace", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"and
695 * 6) When dialog appears select Skip All"
698 * Expected Results: After selecting trace type, verify that button "Import
699 * unrecognized traces" is disabled. 4 CTF traces are imported with trace
700 * type "Generic CTF Trace" . Make sure that these traces can be opened
703 public void test3_17ImportRecursiveSpecifyTraceTypeCTF() {
704 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
706 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
707 importTrace(GENERIC_CTF_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
709 final TestTraceInfo
[] CTF_TRACEINFOS
= new TestTraceInfo
[] {
711 SIMPLE_SERVER1_UST_TRACE
,
712 SIMPLE_SERVER2_UST_TRACE
,
713 UST_OVERLAP_TESTING_UST_TRACE
715 for (TestTraceInfo info
: CTF_TRACEINFOS
) {
716 verifyTrace(info
, optionFlags
, info
.getTraceName(), GENERIC_CTF_TRACE_TYPE
);
719 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
720 assertEquals(CTF_TRACEINFOS
.length
, tracesFolderItem
.getItems().length
);
725 * Action : Recursive import with specific trace type 2 (Skip All)
729 * Procedure : 1) Open Import wizard (see 3.1-3.2)
730 * 2) Browse to directory ${local}/traces/import/
731 * 3) Select directory import
732 * 4) Select trace type "LTTng Kernel Trace", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
734 * 6) When dialog appears select Skip All"
737 * Expected Results: After selecting trace type, verify that button "Import
738 * unrecognized traces" is disabled. One LTTng Kernel trace is imported with
739 * trace type "LTTng Kernel Trace". Make sure that this trace can be opened.
742 public void test3_18ImportRecursiveSpecifyTraceTypeKernel() {
743 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
745 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
746 importTrace(LTTNG_KERNEL_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
748 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
);
750 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
751 assertEquals(1, tracesFolderItem
.getItems().length
);
756 * Action : Recursive import with specific trace type 3 (Skip All)
760 * Procedure : 1) Open Import wizard
761 * 2) Browse to directory ${local}/traces/import/
762 * 3) Select directory import
763 * 4) Select trace type "LTTng UST Trace", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
765 * 6) When dialog appears select Skip All"
768 * Expected Results: After selecting trace type, verify that button "Import
769 * unrecognized traces" is disabled. 3 LTTng UST traces are imported with
770 * trace type "LTTng UST Trace". Make sure that these traces can be opened.
773 public void test3_19ImportRecursiveSpecifyTraceTypeUST() {
774 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
776 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
777 importTrace(LTTNG_UST_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
779 final TestTraceInfo
[] UST_TRACEINFOS
= new TestTraceInfo
[] {
780 SIMPLE_SERVER1_UST_TRACE
,
781 SIMPLE_SERVER2_UST_TRACE
,
782 UST_OVERLAP_TESTING_UST_TRACE
784 for (TestTraceInfo info
: UST_TRACEINFOS
) {
785 verifyTrace(info
, optionFlags
);
788 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
789 assertEquals(UST_TRACEINFOS
.length
, tracesFolderItem
.getItems().length
);
794 * Action : Recursive import with specific trace type 4 (Skip All)
798 * Procedure : 1) Open Import wizard (see 3.1-3.2)
799 * 2) Browse to directory ${local}/traces/import/
800 * 3) select directory import
801 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
803 * 6) When dialog appears select Skip All"
806 * Expected Results: All text files in directories are imported as trace and
807 * trace type "Tmf Generic" is set. Note that trace type validation only
808 * checks for file exists and that file is not a directory. Make sure that
809 * these traces can be opened. However traces with wrong trace type won't
810 * show any events in the table.
813 public void test3_20ImportRecursiveSpecifyTraceTypeCustomText() {
814 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
816 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
817 importTrace(CUSTOM_TEXT_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
818 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
);
820 final TestTraceInfo
[] TEXT_BASED_TRACEINFOS
= new TestTraceInfo
[] {
822 CUSTOM_XML_LOG_AS_TEXT
,
825 for (TestTraceInfo info
: TEXT_BASED_TRACEINFOS
) {
826 verifyTrace(info
, optionFlags
, info
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
829 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
830 assertEquals(TEXT_BASED_TRACEINFOS
.length
, tracesFolderItem
.getItems().length
);
833 private static void verifyTrace(TestTraceInfo traceInfo
, int importOptionFlags
) {
834 verifyTrace(traceInfo
, importOptionFlags
, traceInfo
.getTraceName());
839 * Action : Recursive import with preserved folder structure
843 * Procedure : 0) Delete all traces in project
844 * 1) Open Import wizard
845 * 2) Browse to directory ${local}/traces/import/
846 * 3) Select directory import
847 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and select "Preserve Folder Structure"
851 * Expected Results: All matching traces are imported with trace type set.
852 * The folder "clashes" is imported with traces inside. Make sure that the
853 * traces can be opened.
856 public void test3_29ImportRecursivePreserve() {
857 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
859 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
860 importTrace(CUSTOM_TEXT_TRACE_TYPE
, optionFlags
, ImportConfirmation
.CONTINUE
, "");
862 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
, CUSTOM_TEXT_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
863 verifyTrace(CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, CUSTOM_XML_LOG_AS_TEXT
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
864 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
, UNRECOGNIZED_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
865 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, CLASHES_CUSTOM_TEXT_LOG
.getTracePath(), CUSTOM_TEXT_TRACE_TYPE
);
866 verifyTrace(CLASHES_CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, CLASHES_CUSTOM_XML_LOG_AS_TEXT
.getTracePath(), CUSTOM_TEXT_TRACE_TYPE
);
868 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
869 assertEquals(4, tracesFolderItem
.getItems().length
);
870 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
871 assertEquals(2, clashesFolderItem
.getItems().length
);
876 * Action : Recursive import with preserved folder structure (Skip All)
880 * Procedure : 1) Open Import wizard
881 * 2) Browse to directory ${local}/traces/import/
882 * 3) Select directory import
883 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and select "Preserve Folder Structure"
885 * 6) When dialog appears select "Skip All"
888 * Expected Results: The wizard should finish quickly as no trace will be
889 * imported. Make sure that the traces can be opened.
892 public void test3_30ImportRecursivePreserveSkipAll() {
893 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
894 importTrace(CUSTOM_TEXT_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
896 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
, CUSTOM_TEXT_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
897 verifyTrace(CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, CUSTOM_XML_LOG_AS_TEXT
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
898 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
, UNRECOGNIZED_LOG
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
899 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, CLASHES_CUSTOM_TEXT_LOG
.getTracePath(), CUSTOM_TEXT_TRACE_TYPE
);
900 verifyTrace(CLASHES_CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, CLASHES_CUSTOM_XML_LOG_AS_TEXT
.getTracePath(), CUSTOM_TEXT_TRACE_TYPE
);
902 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
903 assertEquals(4, tracesFolderItem
.getItems().length
);
904 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
905 assertEquals(2, clashesFolderItem
.getItems().length
);
906 //TOOD: verify that traces were actually skipped
911 * Action : Recursive import with preserved folder structure (Rename All)
915 * Procedure : 1) Open Import wizard
916 * 2) Browse to directory ${local}/traces/import/
917 * 3) Select directory import
918 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and select "Preserve Folder Structure"
920 * 6) When dialog appears select "Rename All"
923 * Expected Results: All matching traces are imported with trace type set.
924 * The traces are renamed with suffix (2). The folder "clashes" is imported
925 * with traces inside. Make sure that the traces can be opened.
928 public void test3_31ImportRecursivePreserveRenameAll() {
929 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
| ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
930 importTrace(CUSTOM_TEXT_TRACE_TYPE
, optionFlags
, ImportConfirmation
.RENAME_ALL
, "");
932 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
, toRenamedName(CUSTOM_TEXT_LOG
.getTraceName()), CUSTOM_TEXT_TRACE_TYPE
);
933 verifyTrace(CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, toRenamedName(CUSTOM_XML_LOG_AS_TEXT
.getTraceName()), CUSTOM_TEXT_TRACE_TYPE
);
934 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
, toRenamedName(UNRECOGNIZED_LOG
.getTraceName()), CUSTOM_TEXT_TRACE_TYPE
);
935 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, toRenamedName(CLASHES_CUSTOM_TEXT_LOG
.getTracePath()), CUSTOM_TEXT_TRACE_TYPE
);
936 verifyTrace(CLASHES_CUSTOM_XML_LOG_AS_TEXT
, optionFlags
, toRenamedName(CLASHES_CUSTOM_XML_LOG_AS_TEXT
.getTracePath()), CUSTOM_TEXT_TRACE_TYPE
);
938 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
939 assertEquals(7, tracesFolderItem
.getItems().length
);
940 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
941 assertEquals(4, clashesFolderItem
.getItems().length
);
946 * Action : Import from zip archive with preserved folder structure
950 * Procedure : 0) Delete all traces in project
951 * 1) Open Import wizard
952 * 2) Select archive file: traces.zip
953 * 3) Select archive root directory
954 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
958 * Expected Results: All traces are imported with trace type set. The folder
959 * "clashes" is imported with traces inside. Make sure that the traces can
963 public void test3_36ImportZipArchivePreserve() {
964 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
966 int optionFlags
= ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
967 importTrace("traces.zip", null, optionFlags
, ImportConfirmation
.CONTINUE
, "");
969 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
970 verifyTrace(info
, optionFlags
, info
.getTracePath());
973 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
974 assertEquals(7, tracesFolderItem
.getItems().length
);
975 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
976 assertEquals(6, clashesFolderItem
.getItems().length
);
981 * Action : Import from zip archive without preserved folder structure
986 * Procedure : 0) Delete all traces in project
987 * 1) Open Import wizard
988 * 2) Select archive file: traces.zip
989 * 3) Select archive root directory
990 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and unselect "Preserve Folder Structure"
992 * 6) When dialog appears select "Rename All"
995 * Expected Results: All traces are imported with trace type set. The traces
996 * from folder "clashes" are renamed with suffix (2). Make sure that the
997 * traces can be opened.
1000 public void test3_37ImportZipArchiveNoPreserve() {
1001 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1003 int optionFlags
= 0;
1004 importTrace("traces.zip", null, optionFlags
, ImportConfirmation
.RENAME_ALL
, "");
1006 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
1007 String traceName
= info
.getTraceName();
1008 if (CLASHING_TRACEINFOS
.contains(info
)) {
1009 traceName
= toRenamedName(traceName
);
1011 verifyTrace(info
, optionFlags
, traceName
);
1014 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1015 assertEquals(12, tracesFolderItem
.getItems().length
);
1020 * Action : Import from zip archive specific traces
1024 * Procedure : 0) Delete all traces in project
1025 * 1) Open Import wizard
1026 * 2) Select archive file: traces.zip
1027 * 3) Select file z-clashes/ExampleCustomTxt.log and directory kernel-overlap-testing/
1028 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
1032 * Expected Results: The specified traces are imported with trace type set.
1033 * Make sure that the traces can be opened.
1036 public void test3_38ImportZipArchiveSpecificTraces() {
1037 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1039 int optionFlags
= ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
1040 importTrace("traces.zip", null, optionFlags
, ImportConfirmation
.CONTINUE
, "z-clashes/ExampleCustomTxt.log", "kernel-overlap-testing/");
1042 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, CLASHES_CUSTOM_TEXT_LOG
.getTracePath());
1043 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
, LTTNG_KERNEL_TRACE
.getTracePath());
1045 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1046 assertEquals(2, tracesFolderItem
.getItems().length
);
1047 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
1048 assertEquals(1, clashesFolderItem
.getItems().length
);
1053 * Action : Import from tar.gz archive with preserved folder structure
1057 * Procedure : 0) Delete all traces in project
1058 * 1) Open Import wizard
1059 * 2) Select archive file: traces.tar.gz
1060 * 3) Select archive root directory
1061 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
1065 * Expected Results: All traces are imported with trace type set. The folder
1066 * "clashes" is imported with traces inside. Make sure that the traces can
1070 public void test3_39ImportTarGzipArchivePreserve() {
1071 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1073 int optionFlags
= ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
1074 importTrace("traces.tar.gz", null, optionFlags
, ImportConfirmation
.CONTINUE
, "");
1076 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
1077 verifyTrace(info
, optionFlags
, info
.getTracePath());
1080 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1081 assertEquals(7, tracesFolderItem
.getItems().length
);
1082 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
1083 assertEquals(6, clashesFolderItem
.getItems().length
);
1088 * Action : Import from tar.gz archive without preserved folder structure (Rename All)
1092 * Procedure : 0) Delete all traces in project
1093 * 1) Open Import wizard
1094 * 2) Select archive file: traces.tar.gz
1095 * 3) Select archive root directory
1096 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and unselect "Preserve Folder Structure"
1098 * 6) When dialog appears select "Rename All"
1101 * Expected Results: All traces are imported with trace type set. The traces
1102 * from folder "clashes" are renamed with suffix (2). Make sure that the
1103 * traces can be opened.
1106 public void test3_40ImportTarGzipArchiveNoPreserve() {
1107 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1109 int optionFlags
= 0;
1110 importTrace("traces.tar.gz", null, optionFlags
, ImportConfirmation
.RENAME_ALL
, "");
1112 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
1113 String traceName
= info
.getTraceName();
1114 if (CLASHING_TRACEINFOS
.contains(info
)) {
1115 traceName
= toRenamedName(traceName
);
1117 verifyTrace(info
, optionFlags
, traceName
);
1120 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1121 assertEquals(12, tracesFolderItem
.getItems().length
);
1126 * Action : Import from tar.gz archive specific traces
1130 * Procedure : 0) Delete all traces in project
1131 * 1) Open Import wizard
1132 * 2) Select archive file: traces.tar.gz
1133 * 3) Select file z-clashes/ExampleCustomTxt.log and directory kernel-overlap-testing/
1134 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
1138 * Expected Results: The specified traces are imported with trace type set.
1139 * Make sure that the traces can be opened.
1142 public void test3_41ImportTarGzipArchiveSpecificTraces() {
1143 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
1145 int optionFlags
= ImportTraceWizardPage
.OPTION_PRESERVE_FOLDER_STRUCTURE
;
1146 importTrace("traces.tar.gz", null, optionFlags
, ImportConfirmation
.CONTINUE
, "z-clashes/ExampleCustomTxt.log", "kernel-overlap-testing/");
1148 verifyTrace(CLASHES_CUSTOM_TEXT_LOG
, optionFlags
, CLASHES_CUSTOM_TEXT_LOG
.getTracePath());
1149 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
, LTTNG_KERNEL_TRACE
.getTracePath());
1151 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1152 assertEquals(2, tracesFolderItem
.getItems().length
);
1153 SWTBotTreeItem clashesFolderItem
= SWTBotUtils
.getTraceProjectItem(fBot
, tracesFolderItem
, CLASHES_DIR_NAME
);
1154 assertEquals(1, clashesFolderItem
.getItems().length
);
1157 private static void verifyTrace(TestTraceInfo traceInfo
, int importOptionFlags
, String traceName
) {
1158 verifyTrace(traceInfo
, importOptionFlags
, traceName
, traceInfo
.getTraceType());
1161 private static void verifyTrace(TestTraceInfo traceInfo
, int importOptionFlags
, String traceName
, String traceType
) {
1162 String
[] tracePath
= new Path(traceName
).segments();
1163 SWTBotTreeItem traceItem
= SWTBotUtils
.getTraceProjectItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
), tracePath
);
1164 checkTraceType(traceItem
, traceType
);
1165 openTrace(traceItem
);
1166 if (traceType
!= null && !traceType
.isEmpty()) {
1167 SWTBotImportWizardUtils
.testEventsTable(fBot
, traceName
, traceInfo
.getNbEvents(), traceInfo
.getFirstEventTimestamp());
1169 // If there is no trace type, make sure it can be opened with the text editor
1170 fBot
.waitUntil(ConditionHelpers
.isEditorOpened(fBot
, traceName
));
1171 SWTBotEditor editor
= fBot
.editorByTitle(traceName
);
1172 assertEquals(TEXT_EDITOR_ID
, editor
.getReference().getId());
1174 checkTraceLinked(traceItem
, (importOptionFlags
& ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
) != 0);
1177 private static String
toRenamedName(String traceName
) {
1178 return traceName
+ "(2)";
1181 private static void openTrace(SWTBotTreeItem traceItem
) {
1183 traceItem
.doubleClick();
1186 private static void testSingleTrace(TestTraceInfo traceInfo
, int optionFlags
) {
1187 importTrace(optionFlags
, traceInfo
.getTracePath());
1188 verifyTrace(traceInfo
, optionFlags
);
1191 private static void importTrace(int optionFlags
, String
... tracePaths
) {
1192 importTrace(optionFlags
, ImportConfirmation
.CONTINUE
, tracePaths
);
1195 private static void importTrace(int optionFlags
, ImportConfirmation confirmationMode
, String
... tracePaths
) {
1196 importTrace(null, optionFlags
, confirmationMode
, tracePaths
);
1199 private static void importTrace(String traceType
, int optionFlags
, ImportConfirmation confirmationMode
, String
... tracePaths
) {
1200 importTrace(null, traceType
, optionFlags
, confirmationMode
, tracePaths
);
1203 private static void importTrace(String archiveFile
, String traceType
, int optionFlags
, ImportConfirmation confirmationMode
, String
... tracePaths
) {
1204 importTrace(archiveFile
, traceType
, optionFlags
, new Supplier
<ImportConfirmation
>() {
1205 boolean fDone
= false;
1207 public ImportConfirmation
get() {
1212 return confirmationMode
;
1217 private static void importTrace(int optionFlags
, Supplier
<ImportConfirmation
> confirmationSuplier
, String
... tracePaths
) {
1218 importTrace(null, null, optionFlags
, confirmationSuplier
, tracePaths
);
1222 * @param tracePaths relative to parent test traces folder
1224 private static void importTrace(String archiveFile
, String traceType
, int optionFlags
, Supplier
<ImportConfirmation
> confirmationSuplier
, String
... tracePaths
) {
1225 SWTBotTreeItem traceFolder
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
1227 SWTBotShell shell
= openTraceFoldersImport(traceFolder
);
1228 SWTBot bot
= shell
.bot();
1229 String rootFolderName
;
1230 if (archiveFile
== null) {
1231 rootFolderName
= "import";
1232 String importDirectoryFullPath
= getPath(rootFolderName
);
1233 SWTBotImportWizardUtils
.selectImportFromDirectory(bot
, importDirectoryFullPath
);
1235 rootFolderName
= "/";
1236 String importArchiveFullPath
= getPath("archives" + File
.separator
+ archiveFile
);
1237 SWTBotImportWizardUtils
.selectImportFromArchive(bot
, importArchiveFullPath
);
1240 for (String tracePath
: tracePaths
) {
1241 IPath somePath
= new Path(rootFolderName
).append(tracePath
);
1242 String
[] treePath
= somePath
.segments();
1243 if (archiveFile
!= null) {
1244 String
[] newPath
= new String
[treePath
.length
+ 1];
1246 System
.arraycopy(treePath
, 0, newPath
, 1, treePath
.length
);
1249 SWTBotImportWizardUtils
.selectItem(fBot
, treePath
);
1252 SWTBotImportWizardUtils
.setOptions(bot
, optionFlags
, traceType
);
1253 bot
.button("Finish").click();
1255 ImportConfirmation importConfirmation
= confirmationSuplier
.get();
1256 while (importConfirmation
!= null) {
1257 if (importConfirmation
!= ImportConfirmation
.CONTINUE
) {
1258 fBot
.waitUntil(Conditions
.shellIsActive("Confirmation"));
1259 SWTBotShell shell2
= fBot
.activeShell();
1260 SWTBotButton button
= shell2
.bot().button(importConfirmation
.getInName());
1263 importConfirmation
= confirmationSuplier
.get();
1266 fBot
.waitUntil(Conditions
.shellCloses(shell
));
1269 private static void checkTraceType(SWTBotTreeItem traceItem
, String traceType
) {
1270 assertEquals(traceType
, getTraceProperty(traceItem
, "type"));
1273 private static void checkTraceLinked(SWTBotTreeItem traceItem
, boolean linked
) {
1274 assertEquals(Boolean
.toString(linked
), getTraceProperty(traceItem
, "linked"));
1277 private static String
getTraceProperty(SWTBotTreeItem traceItem
, String property
) {
1278 SWTBotUtils
.openView(IPageLayout
.ID_PROP_SHEET
);
1279 SWTBotView view
= fBot
.viewById(IPageLayout
.ID_PROP_SHEET
);
1282 SWTBotTreeItem traceTypeItem
= SWTBotUtils
.getTreeItem(view
.bot(), view
.bot().tree(), "Resource properties", property
);
1283 return traceTypeItem
.cell(1);
1286 private static SWTBotShell
openTraceFoldersImport(SWTBotTreeItem traceItem
) {
1287 traceItem
.contextMenu().menu("Import...").click();
1288 fBot
.waitUntil(Conditions
.shellIsActive("Trace Import"));
1290 SWTBotShell shell
= fBot
.shell("Trace Import");