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
.ui
.IPageLayout
;
45 import org
.junit
.AfterClass
;
46 import org
.junit
.BeforeClass
;
47 import org
.junit
.FixMethodOrder
;
48 import org
.junit
.Test
;
49 import org
.junit
.runner
.RunWith
;
50 import org
.junit
.runners
.MethodSorters
;
52 import com
.google
.common
.collect
.ImmutableList
;
53 import com
.google
.common
.collect
.ImmutableSet
;
56 * SWTBot test for testing Project Explorer trace folders (context-menu,
59 @RunWith(SWTBotJunit4ClassRunner
.class)
60 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
61 @SuppressWarnings({"restriction", "javadoc"})
62 public class ProjectExplorerTracesFolderTest
{
64 private static final String PROP_LAST_MODIFIED_PROPERTY
= "last modified";
65 private static final String TEXT_EDITOR_ID
= "org.eclipse.ui.DefaultTextEditor";
67 private static final String GENERIC_CTF_TRACE_TYPE
= "Common Trace Format : Generic CTF Trace";
68 private static final String LTTNG_KERNEL_TRACE_TYPE
= "Common Trace Format : Linux Kernel Trace";
69 private static final String LTTNG_UST_TRACE_TYPE
= "Common Trace Format : LTTng UST Trace";
70 private static final String CUSTOM_TEXT_TRACE_TYPE
= "Custom Text : TmfGeneric";
71 private static final String CUSTOM_XML_TRACE_TYPE
= "Custom XML : Custom XML Log";
73 private static final @NonNull TestTraceInfo CUSTOM_TEXT_LOG
= new TestTraceInfo("ExampleCustomTxt.log", CUSTOM_TEXT_TRACE_TYPE
, 10, "29:52.034");
74 private static final @NonNull TestTraceInfo CUSTOM_XML_LOG
= new TestTraceInfo("ExampleCustomXml.xml", CUSTOM_XML_TRACE_TYPE
, 6, "22:01:20");
75 private static final @NonNull TestTraceInfo LTTNG_KERNEL_TRACE
= new TestTraceInfo("kernel-overlap-testing", LTTNG_KERNEL_TRACE_TYPE
, 1000, "04:32.650 993 664");
76 private static final @NonNull TestTraceInfo SIMPLE_SERVER1_UST_TRACE
= new TestTraceInfo("simple_server-thread1", LTTNG_UST_TRACE_TYPE
, 1000, "04:32.650 993 664");
77 private static final @NonNull TestTraceInfo SIMPLE_SERVER2_UST_TRACE
= new TestTraceInfo("simple_server-thread2", LTTNG_UST_TRACE_TYPE
, 1000, "04:32.650 993 664");
78 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");
80 private static final String CLASHES_DIR_NAME
= "z-clashes";
81 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");
82 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");
83 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");
84 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");
85 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");
86 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");
89 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(),
90 LTTNG_KERNEL_TRACE
.getFirstEventTimestamp());
91 private static final @NonNull TestTraceInfo UNRECOGNIZED_LOG
= new TestTraceInfo("unrecognized.log", "", 0, "");
92 private static final @NonNull TestTraceInfo CUSTOM_XML_LOG_AS_TEXT
= new TestTraceInfo("ExampleCustomXml.xml", CUSTOM_TEXT_TRACE_TYPE
, 0, "");
94 private static final TestTraceInfo
[] ALL_TRACEINFOS
= new TestTraceInfo
[] {
98 SIMPLE_SERVER1_UST_TRACE
,
99 SIMPLE_SERVER2_UST_TRACE
,
100 UST_OVERLAP_TESTING_UST_TRACE
,
102 CLASHES_CUSTOM_TEXT_LOG
,
103 CLASHES_CUSTOM_XML_LOG
,
104 CLASHES_LTTNG_KERNEL_TRACE
,
105 CLASHES_SIMPLE_SERVER1_UST_TRACE
,
106 CLASHES_SIMPLE_SERVER2_UST_TRACE
,
107 CLASHES_UST_OVERLAP_TESTING_UST_TRACE
110 private static final Set
<TestTraceInfo
> CLASHING_TRACEINFOS
= ImmutableSet
.of(
111 CLASHES_CUSTOM_TEXT_LOG
,
112 CLASHES_CUSTOM_XML_LOG
,
113 CLASHES_LTTNG_KERNEL_TRACE
,
114 CLASHES_SIMPLE_SERVER1_UST_TRACE
,
115 CLASHES_SIMPLE_SERVER2_UST_TRACE
,
116 CLASHES_UST_OVERLAP_TESTING_UST_TRACE
);
118 // All normal traces plus the unrecognized trace
119 private static final int NUM_UNIQUE_TRACES
= CLASHING_TRACEINFOS
.size() + 1;
122 private static final File TEST_TRACES_PATH
= new File(new Path(TmfTraceManager
.getTemporaryDirPath()).append("testtraces").toOSString());
123 private static final String TRACE_PROJECT_NAME
= "test";
124 private static final String MANAGE_CUSTOM_PARSERS_SHELL_TITLE
= "Manage Custom Parsers";
126 private static SWTWorkbenchBot fBot
;
128 /** The Log4j logger instance. */
129 private static final Logger fLogger
= Logger
.getRootLogger();
131 private static String
getPath(String relativePath
) {
132 return new Path(TEST_TRACES_PATH
.getAbsolutePath()).append(relativePath
).toOSString();
138 * @throws IOException
141 public static void init() throws IOException
{
142 TestDirectoryStructureUtil
.generateTraceStructure(TEST_TRACES_PATH
);
144 SWTBotUtils
.initialize();
146 /* Set up for swtbot */
147 SWTBotPreferences
.TIMEOUT
= 20000; /* 20 second timeout */
148 SWTBotPreferences
.KEYBOARD_LAYOUT
= "EN_US";
149 fLogger
.removeAllAppenders();
150 fLogger
.addAppender(new NullAppender());
151 fBot
= new SWTWorkbenchBot();
153 SWTBotUtils
.closeView("Welcome", fBot
);
155 SWTBotUtils
.switchToTracingPerspective();
157 /* Finish waiting for eclipse to load */
158 SWTBotUtils
.waitForJobs();
159 SWTBotUtils
.createProject(TRACE_PROJECT_NAME
);
163 * Test class tear down method.
166 public static void tearDown() {
167 SWTBotUtils
.deleteProject(TRACE_PROJECT_NAME
, fBot
);
168 fLogger
.removeAllAppenders();
171 private static void test3_01Preparation() {
172 // 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
173 CustomTxtTraceDefinition
[] txtDefinitions
= CustomTxtTraceDefinition
.loadAll(getPath("customParsers/ExampleCustomTxtParser.xml"));
174 txtDefinitions
[0].save();
175 CustomXmlTraceDefinition
[] xmlDefinitions
= CustomXmlTraceDefinition
.loadAll(getPath("customParsers/ExampleCustomXmlParser.xml"));
176 xmlDefinitions
[0].save();
178 SWTBotTreeItem traceFolder
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
179 traceFolder
.contextMenu("Manage Custom Parsers...").click();
180 fBot
.waitUntil(Conditions
.shellIsActive(MANAGE_CUSTOM_PARSERS_SHELL_TITLE
));
181 SWTBotShell shell
= fBot
.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE
);
182 SWTBot shellBot
= shell
.bot();
184 // Make sure the custom text trace type is imported
185 shellBot
.list().select(CUSTOM_TEXT_LOG
.getTraceType());
187 // Make sure the custom xml trace type is imported
188 shellBot
.radio("XML").click();
189 shellBot
.list().select(CUSTOM_XML_LOG
.getTraceType());
190 shellBot
.button("Close").click();
191 shellBot
.waitUntil(Conditions
.shellCloses(shell
));
195 * Test that the expected context menu items are there
197 * Action : Trace Folder menu
199 * Procedure :Select the Traces folder and open its context menu
201 * Expected Results: Correct menu opens (Import, Refresh, etc)
204 public void test3_01ContextMenuPresence() {
205 test3_01Preparation();
207 SWTBotTreeItem traceItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
209 final List
<String
> EXPECTED_MENU_LABELS
= ImmutableList
.of(
217 "Import Trace Package...",
218 "Fetch Remote Traces...",
220 "Export Trace Package...",
222 "Manage Custom Parsers...",
223 "Manage XML analyses...",
225 "Apply Time Offset...",
230 List
<String
> menuLabels
= traceItem
.contextMenu().menuItems();
231 for (int i
= 0; i
< menuLabels
.size(); i
++) {
232 assertEquals(EXPECTED_MENU_LABELS
.get(i
), menuLabels
.get(i
));
235 fBot
.closeAllEditors();
239 * Test that the trace import wizard appears
241 * Action : Trace Import Wizard
243 * Procedure : Select Import
245 * Expected Results: Trace Import Wizard appears
248 public void test3_02Import() {
249 SWTBotTreeItem traceItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
251 SWTBotShell shell
= openTraceFoldersImport(traceItem
);
252 shell
.bot().button("Cancel").click();
256 * Test that the trace import wizard can import a single custom text trace
258 * Action : Import single custom text trace (link to workspace)
261 * Procedure : 1) Browse to directory ${local}/traces/import/
262 * 2) Select trace ExampleCustomTxt.log
263 * 3) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning" and select "Create Links to workspace" and
267 * Expected Results: Imported trace appear in Traces Folder and the Trace Type Tmf Generic is set. Make sure trace can be opened
270 public void test3_03SingleCustomTextTrace() {
271 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
272 testSingleTrace(CUSTOM_TEXT_LOG
, optionFlags
);
277 * Action : Import Single custom XML trace (link to workspace)
281 * Procedure : redo 3.1-3.3 but this time select ExampleCustomXml.xml
284 * Expected Results: Imported trace appear in Traces Folder and the Trace
285 * Type "Custom XML log" is set. Make sure that trace can be opened
288 public void test3_04SingleCustomXmlTrace() {
289 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
290 testSingleTrace(CUSTOM_XML_LOG
, optionFlags
);
295 * Action : Import LTTng Kernel CTF trace (link to workspace)
299 * Procedure : redo 3.1-3.3 but this time select directory kernel-overlap-testing/
302 * Expected Results: Imported trace appear in Traces Folder and the Trace
303 * Type "LTTng Kernel" is set. Make sure that trace can be opened
306 public void test3_05SingleCtfTrace() {
307 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
308 testSingleTrace(LTTNG_KERNEL_TRACE
, optionFlags
);
313 * Action : Rename + copy import
317 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace"
318 * 2) When dialog box appear select Rename
321 * Expected Results: Traces are imported with new name that has a suffix (2)
322 * at the end. Make sure that imported traces are copied to the project.
325 public void test3_06RenameCopyImport() {
326 testRenameCopyImport(CUSTOM_TEXT_LOG
);
327 testRenameCopyImport(CUSTOM_XML_LOG
);
328 testRenameCopyImport(LTTNG_KERNEL_TRACE
);
331 private static void testRenameCopyImport(TestTraceInfo traceInfo
) {
332 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
;
333 importTrace(optionFlags
, ImportConfirmation
.RENAME
, traceInfo
.getTraceName());
334 String renamed
= toRenamedName(traceInfo
.getTraceName());
335 verifyTrace(traceInfo
, optionFlags
, renamed
);
340 * Action : Overwrite + copy import
344 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace"
345 * 2) When dialog box appear select Overwrite
348 * Expected Results: Existing traces are deleted and new traces are
349 * imported. Make sure that imported traces are copied to the project and
353 public void test3_07OverwriteCopyImport() {
354 testOverwriteCopyImport(CUSTOM_TEXT_LOG
);
355 testOverwriteCopyImport(CUSTOM_XML_LOG
);
356 testOverwriteCopyImport(LTTNG_KERNEL_TRACE
);
359 private static void testOverwriteCopyImport(TestTraceInfo traceInfo
) {
360 String traceName
= traceInfo
.getTraceName();
361 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
), traceName
);
362 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
363 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
;
364 importTrace(optionFlags
, ImportConfirmation
.OVERWRITE
, traceName
);
365 verifyTrace(traceInfo
, optionFlags
);
367 assertNotEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
376 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace"
377 * 2) When dialog box appear select Skip
380 * Expected Results: Make sure that no new trace is imported
383 public void test3_08SkipImport() {
384 testSkipImport(CUSTOM_TEXT_LOG
);
385 testSkipImport(CUSTOM_XML_LOG
);
386 testSkipImport(LTTNG_KERNEL_TRACE
);
389 private static void testSkipImport(TestTraceInfo traceInfo
) {
390 String traceName
= traceInfo
.getTraceName();
391 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
), traceName
);
392 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
393 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
;
394 importTrace(optionFlags
, ImportConfirmation
.SKIP
, traceName
);
395 verifyTrace(traceInfo
, optionFlags
);
397 assertEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
402 * Action : Default overwrite
406 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace" and select "Overwrite existing without warning"
409 * Expected Results: Make sure that no dialog box appears (for renaming,
410 * overwriting, skipping) and existing traces are overwritten). Make sure
411 * trace can be opened
414 public void test3_09OverwriteOptionImport() {
415 testOverwriteOptionImport(CUSTOM_TEXT_LOG
);
416 testOverwriteOptionImport(CUSTOM_XML_LOG
);
417 testOverwriteOptionImport(LTTNG_KERNEL_TRACE
);
420 private static void testOverwriteOptionImport(TestTraceInfo traceInfo
) {
421 String traceName
= traceInfo
.getTraceName();
422 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
), traceName
);
423 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
425 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_OVERWRITE_EXISTING_RESOURCES
;
426 importTrace(optionFlags
, ImportConfirmation
.CONTINUE
, traceName
);
427 verifyTrace(traceInfo
, optionFlags
);
429 assertNotEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
434 * Action : Import unrecognized
438 * Procedure : 1) Open Import wizard (see 3.1-3.2)
439 * 2) Browse to directory ${local}/traces/import
440 * 3) Select trace unrecognized.log
441 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning" and select "Create Links to workspace" and
445 * Expected Results: unrecognized.log is imported with trace type unknown.
446 * The default text file icon is displayed. The trace, when opened, is
447 * displayed in the text editor.
450 public void test3_10ImportUnrecognized() {
451 String traceName
= UNRECOGNIZED_LOG
.getTraceName();
452 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
453 importTrace(optionFlags
, traceName
);
454 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
459 * Action : Import unrecognized (ignore)
463 * Procedure : 1) redo 3.10, however unselect "Import unrecognized traces"
466 * Expected Results: unrecognized.log is not imported
469 public void test3_11ImportUnrecognizedIgnore() {
470 String traceName
= UNRECOGNIZED_LOG
.getTraceName();
471 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
472 int numTraces
= tracesFolderItem
.getItems().length
;
474 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, tracesFolderItem
, traceName
);
475 String lastModified
= getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
);
477 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
478 importTrace(optionFlags
, traceName
);
479 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
481 assertEquals(lastModified
, getTraceProperty(traceItem
, PROP_LAST_MODIFIED_PROPERTY
));
482 assertEquals(numTraces
, tracesFolderItem
.getItems().length
);
487 * Action : Import CTF trace by selection metadata file only
491 * Procedure : 1) Redo 3.5, However only select metadata file instead of directory trace
494 * Expected Results: Imported trace appear in Traces Folder and the Trace
495 * Type "LTTng Kernel" is set. Make sure that trace can be opened
498 public void test3_12ImportCtfWithMetadataSelection() {
499 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
500 testSingleTrace(LTTNG_KERNEL_TRACE_METADATA
, ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
);
505 * Action : Recursive import with auto-detection (Rename All)
509 * Procedure : 1) Open Import wizard (see 3.1-3.2)
510 * 2) Browse to directory ${local}/traces/import
511 * 3) select directory import
512 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
514 * 6) When dialog appears select "Rename All"
517 * Expected Results: All Traces are imported with respective trace type set.
518 * Traces with name clashes are imported with suffix (2). 1 trace
519 * (unrecognized.log) is imported with trace type unknown. Make sure that
520 * traces can be opened which have a trace type set. The unknown trace type
521 * should open with the text editor.
524 public void test3_13ImportRecursiveAutoRenameAll() {
525 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
527 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
528 importTrace(optionFlags
, ImportConfirmation
.RENAME_ALL
, "");
530 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
531 String traceName
= info
.getTraceName();
532 if (CLASHING_TRACEINFOS
.contains(info
)) {
533 traceName
= toRenamedName(traceName
);
535 verifyTrace(info
, optionFlags
, traceName
);
538 // Also check unrecognized file
539 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
544 * Action : Recursive import with auto-detection (Overwrite All)
548 * Procedure : 1) Open Import wizard (see 3.1-3.2)
549 * 2) Browse to directory ${local}/traces/import/
550 * 3) select directory import
551 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
553 * 6) When dialog appears select Overwrite All"
556 * Expected Results: All Traces are imported with respective trace type set.
557 * Traces with name clashes are overwritten . 1 trace (unrecognized.log) is
558 * imported with trace type unknown. Make sure that traces can be opened
559 * which have a trace type set. The unknown trace type should open with the
563 public void test3_14ImportRecursiveAutoOverwriteAll() {
564 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
566 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
567 importTrace(optionFlags
, ImportConfirmation
.OVERWRITE_ALL
, "");
569 for (TestTraceInfo info
: CLASHING_TRACEINFOS
) {
570 verifyTrace(info
, optionFlags
);
573 // All traces should have clashed/overwritten (plus the unrecognized trace)
574 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
575 assertEquals(NUM_UNIQUE_TRACES
, tracesFolderItem
.getItems().length
);
577 // Also check unrecognized file
578 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
583 * Action : Recursive import with auto-detection (Skip All)
587 * Procedure : 1) Open Import wizard (see 3.1-3.2)
588 * 2) Browse to directory ${local}/traces/import/
589 * 3) select directory import
590 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning" and select "Create Links to workspace" and uncheck "preserve folder structure"
592 * 6) When dialog appears select Skip All"
595 * Expected Results: All Traces are imported with respective trace type set. Traces with name
596 * clashes are not imported. 1 trace (unrecognized.log) is imported with
597 * trace type unknown. The unknown trace type should open with the text
601 public void test3_15ImportRecursiveAutoSkipAll() {
602 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
604 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
605 importTrace(optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
607 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
608 for (TestTraceInfo info
: ALL_TRACEINFOS
) {
609 if (!CLASHING_TRACEINFOS
.contains(info
)) {
610 verifyTrace(info
, optionFlags
);
614 // All traces should have skipped (plus the unrecognized trace)
615 assertEquals(NUM_UNIQUE_TRACES
, tracesFolderItem
.getItems().length
);
617 // Also check unrecognized file
618 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
623 * Action : Recursive import with auto-detection (test rename, overwrite and
628 * Procedure : 1) Open Import wizard (see 3.1-3.2)
629 * 2) Browse to directory ${local}/traces/import/
630 * 3) select directory import
631 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
633 * 6) When dialog appears select "Rename"
634 * 7) When dialog appears select "Overwrite"
635 * 8) When dialog appears select "Skip"
638 * Expected Results: All Traces are imported with respective trace type set. Traces with name
639 * clashes are either renamed, overwritten or skipped as per dialog action.
640 * Make sure that traces can be opened which have trace type set. The
641 * unknown trace type should open with the text editor.
644 public void test3_16ImportRecursiveAutoRenameOverwriteSkip() {
645 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
647 Supplier
<ImportConfirmation
> confirmationSupplier
= new Supplier
<ImportConfirmation
>() {
648 final ImportConfirmation dialogConfirmationOrder
[] = new ImportConfirmation
[] { ImportConfirmation
.RENAME
, ImportConfirmation
.OVERWRITE
, ImportConfirmation
.SKIP
};
652 public ImportConfirmation
get() {
653 if (fRsponseNum
>= dialogConfirmationOrder
.length
) {
657 ImportConfirmation confirmation
= dialogConfirmationOrder
[fRsponseNum
];
662 int optionFlags
= ImportTraceWizardPage
.OPTION_IMPORT_UNRECOGNIZED_TRACES
| ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
663 importTrace(optionFlags
, confirmationSupplier
, LTTNG_KERNEL_TRACE
.getTracePath(), CLASHES_LTTNG_KERNEL_TRACE
.getTracePath(), SIMPLE_SERVER1_UST_TRACE
.getTracePath(), CLASHES_SIMPLE_SERVER1_UST_TRACE
.getTracePath(),
664 SIMPLE_SERVER2_UST_TRACE
.getTracePath(), CLASHES_SIMPLE_SERVER2_UST_TRACE
.getTracePath(), UNRECOGNIZED_LOG
.getTracePath());
666 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
);
669 String renamed
= toRenamedName(CLASHES_LTTNG_KERNEL_TRACE
.getTraceName());
670 verifyTrace(CLASHES_LTTNG_KERNEL_TRACE
, optionFlags
, renamed
);
673 verifyTrace(CLASHES_SIMPLE_SERVER1_UST_TRACE
, optionFlags
);
676 verifyTrace(SIMPLE_SERVER2_UST_TRACE
, optionFlags
);
678 // Also check unrecognized file
679 verifyTrace(UNRECOGNIZED_LOG
, optionFlags
);
684 * Action : Recursive import with specific trace type 1 (Skip All) skip)
688 * Procedure : 1) Open Import wizard
689 * 2) Browse to directory ${local}/traces/import/
690 * 3) Select directory import
691 * 4) Select trace type "Generic CTF Trace", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"and
693 * 6) When dialog appears select Skip All"
696 * Expected Results: After selecting trace type, verify that button "Import
697 * unrecognized traces" is disabled. 4 CTF traces are imported with trace
698 * type "Generic CTF Trace" . Make sure that these traces can be opened
701 public void test3_17ImportRecursiveSpecityTraceTypeCTF() {
702 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
704 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
705 importTrace(GENERIC_CTF_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
707 final TestTraceInfo
[] CTF_TRACEINFOS
= new TestTraceInfo
[] {
709 SIMPLE_SERVER1_UST_TRACE
,
710 SIMPLE_SERVER2_UST_TRACE
,
711 UST_OVERLAP_TESTING_UST_TRACE
713 for (TestTraceInfo info
: CTF_TRACEINFOS
) {
714 verifyTrace(info
, optionFlags
, info
.getTraceName(), GENERIC_CTF_TRACE_TYPE
);
717 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
718 assertEquals(CTF_TRACEINFOS
.length
, tracesFolderItem
.getItems().length
);
723 * Action : Recursive import with specific trace type 2 (Skip All)
727 * Procedure : 1) Open Import wizard (see 3.1-3.2)
728 * 2) Browse to directory ${local}/traces/import/
729 * 3) Select directory import
730 * 4) Select trace type "LTTng Kernel Trace", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
732 * 6) When dialog appears select Skip All"
735 * Expected Results: After selecting trace type, verify that button "Import
736 * unrecognized traces" is disabled. One LTTng Kernel trace is imported with
737 * trace type "LTTng Kernel Trace". Make sure that this trace can be opened.
740 public void test3_18ImportRecursiveSpecityTraceTypeKernel() {
741 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
743 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
744 importTrace(LTTNG_KERNEL_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
746 verifyTrace(LTTNG_KERNEL_TRACE
, optionFlags
);
748 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
749 assertEquals(1, tracesFolderItem
.getItems().length
);
754 * Action : Recursive import with specific trace type 3 (Skip All)
758 * Procedure : 1) Open Import wizard
759 * 2) Browse to directory ${local}/traces/import/
760 * 3) Select directory import
761 * 4) Select trace type "LTTng UST Trace", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
763 * 6) When dialog appears select Skip All"
766 * Expected Results: After selecting trace type, verify that button "Import
767 * unrecognized traces" is disabled. 3 LTTng UST traces are imported with
768 * trace type "LTTng UST Trace". Make sure that these traces can be opened.
771 public void test3_19ImportRecursiveSpecityTraceTypeUST() {
772 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
774 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
775 importTrace(LTTNG_UST_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
777 final TestTraceInfo
[] UST_TRACEINFOS
= new TestTraceInfo
[] {
778 SIMPLE_SERVER1_UST_TRACE
,
779 SIMPLE_SERVER2_UST_TRACE
,
780 UST_OVERLAP_TESTING_UST_TRACE
782 for (TestTraceInfo info
: UST_TRACEINFOS
) {
783 verifyTrace(info
, optionFlags
);
786 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
787 assertEquals(UST_TRACEINFOS
.length
, tracesFolderItem
.getItems().length
);
792 * Action : Recursive import with specific trace type 4 (Skip All)
796 * Procedure : 1) Open Import wizard (see 3.1-3.2)
797 * 2) Browse to directory ${local}/traces/import/
798 * 3) select directory import
799 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
801 * 6) When dialog appears select Skip All"
804 * Expected Results: All text files in directories are imported as trace and
805 * trace type "Tmf Generic" is set. Note that trace type validation only
806 * checks for file exists and that file is not a directory. Make sure that
807 * these traces can be opened. However traces with wrong trace type won't
808 * show any events in the table.
811 public void test3_20ImportRecursiveSpecityTraceTypeCustomText() {
812 SWTBotUtils
.clearTracesFolderUI(fBot
, TRACE_PROJECT_NAME
);
814 int optionFlags
= ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
;
815 importTrace(CUSTOM_TEXT_TRACE_TYPE
, optionFlags
, ImportConfirmation
.SKIP_ALL
, "");
816 verifyTrace(CUSTOM_TEXT_LOG
, optionFlags
);
818 final TestTraceInfo
[] TEXT_BASED_TRACEINFOS
= new TestTraceInfo
[] {
820 CUSTOM_XML_LOG_AS_TEXT
,
823 for (TestTraceInfo info
: TEXT_BASED_TRACEINFOS
) {
824 verifyTrace(info
, optionFlags
, info
.getTraceName(), CUSTOM_TEXT_TRACE_TYPE
);
827 SWTBotTreeItem tracesFolderItem
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
828 assertEquals(TEXT_BASED_TRACEINFOS
.length
, tracesFolderItem
.getItems().length
);
831 private static void verifyTrace(TestTraceInfo traceInfo
, int importOptionFlags
) {
832 verifyTrace(traceInfo
, importOptionFlags
, traceInfo
.getTraceName());
835 private static void verifyTrace(TestTraceInfo traceInfo
, int importOptionFlags
, String traceName
) {
836 verifyTrace(traceInfo
, importOptionFlags
, traceName
, traceInfo
.getTraceType());
839 private static void verifyTrace(TestTraceInfo traceInfo
, int importOptionFlags
, String traceName
, String traceType
) {
840 SWTBotTreeItem traceItem
= SWTBotUtils
.getTreeItem(fBot
, SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
), traceName
);
841 checkTraceType(traceItem
, traceType
);
842 openTrace(traceItem
);
843 if (traceType
!= null && !traceType
.isEmpty()) {
844 SWTBotImportWizardUtils
.testEventsTable(fBot
, traceName
, traceInfo
.getNbEvents(), traceInfo
.getFirstEventTimestamp());
846 // If there is no trace type, make sure it can be opened with the text editor
847 fBot
.waitUntil(ConditionHelpers
.isEditorOpened(fBot
, traceName
));
848 SWTBotEditor editor
= fBot
.editorByTitle(traceName
);
849 assertEquals(TEXT_EDITOR_ID
, editor
.getReference().getId());
851 checkTraceLinked(traceItem
, (importOptionFlags
& ImportTraceWizardPage
.OPTION_CREATE_LINKS_IN_WORKSPACE
) != 0);
854 private static String
toRenamedName(String traceName
) {
855 return traceName
+ "(2)";
858 private static void openTrace(SWTBotTreeItem traceItem
) {
860 traceItem
.doubleClick();
863 private static void testSingleTrace(TestTraceInfo traceInfo
, int optionFlags
) {
864 importTrace(optionFlags
, traceInfo
.getTracePath());
865 verifyTrace(traceInfo
, optionFlags
);
868 private static void importTrace(int optionFlags
, String
... tracePaths
) {
869 importTrace(optionFlags
, ImportConfirmation
.CONTINUE
, tracePaths
);
872 private static void importTrace(int optionFlags
, ImportConfirmation confirmationMode
, String
... tracePaths
) {
873 importTrace(null, optionFlags
, confirmationMode
, tracePaths
);
876 private static void importTrace(String traceType
, int optionFlags
, ImportConfirmation confirmationMode
, String
... tracePaths
) {
877 importTrace(traceType
, optionFlags
, new Supplier
<ImportConfirmation
>() {
878 boolean fDone
= false;
880 public ImportConfirmation
get() {
885 return confirmationMode
;
890 private static void importTrace(int optionFlags
, Supplier
<ImportConfirmation
> confirmationSuplier
, String
... tracePaths
) {
891 importTrace(null, optionFlags
, confirmationSuplier
, tracePaths
);
895 * @param tracePath relative to parent test traces folder
897 private static void importTrace(String traceType
, int optionFlags
, Supplier
<ImportConfirmation
> confirmationSuplier
, String
... tracePaths
) {
898 SWTBotTreeItem traceFolder
= SWTBotUtils
.selectTracesFolder(fBot
, TRACE_PROJECT_NAME
);
900 SWTBotShell shell
= openTraceFoldersImport(traceFolder
);
901 SWTBot bot
= shell
.bot();
902 final String importDirectoryRelativePath
= "import";
903 String importDirectoryFullPath
= getPath(importDirectoryRelativePath
);
905 for (String tracePath
: tracePaths
) {
906 IPath somePath
= new Path(importDirectoryRelativePath
).append(tracePath
);
907 IPath fullParentPath
= somePath
.removeLastSegments(1);
908 boolean isDirectory
= new Path(importDirectoryFullPath
).append(tracePath
).toFile().isDirectory();
910 SWTBotImportWizardUtils
.selectImportFromDirectory(bot
, importDirectoryFullPath
);
912 SWTBotImportWizardUtils
.selectFolder(fBot
, true, somePath
.segments());
914 SWTBotImportWizardUtils
.selectFile(bot
, new Path(tracePath
).lastSegment(), fullParentPath
.segments());
918 SWTBotImportWizardUtils
.setOptions(bot
, optionFlags
, traceType
);
919 bot
.button("Finish").click();
921 ImportConfirmation importConfirmation
= confirmationSuplier
.get();
922 while (importConfirmation
!= null) {
923 if (importConfirmation
!= ImportConfirmation
.CONTINUE
) {
924 fBot
.waitUntil(Conditions
.shellIsActive("Confirmation"));
925 SWTBotShell shell2
= fBot
.activeShell();
926 SWTBotButton button
= shell2
.bot().button(importConfirmation
.getInName());
929 importConfirmation
= confirmationSuplier
.get();
932 fBot
.waitUntil(Conditions
.shellCloses(shell
));
935 private static void checkTraceType(SWTBotTreeItem traceItem
, String traceType
) {
936 assertEquals(traceType
, getTraceProperty(traceItem
, "type"));
939 private static void checkTraceLinked(SWTBotTreeItem traceItem
, boolean linked
) {
940 assertEquals(Boolean
.toString(linked
), getTraceProperty(traceItem
, "linked"));
943 private static String
getTraceProperty(SWTBotTreeItem traceItem
, String property
) {
944 SWTBotUtils
.openView(IPageLayout
.ID_PROP_SHEET
);
945 SWTBotView view
= fBot
.viewById(IPageLayout
.ID_PROP_SHEET
);
948 SWTBotTreeItem traceTypeItem
= SWTBotUtils
.getTreeItem(view
.bot(), view
.bot().tree(), "Resource properties", property
);
949 return traceTypeItem
.cell(1);
952 private static SWTBotShell
openTraceFoldersImport(SWTBotTreeItem traceItem
) {
953 traceItem
.contextMenu().menu("Import...").click();
954 fBot
.waitUntil(Conditions
.shellIsActive("Trace Import"));
956 SWTBotShell shell
= fBot
.shell("Trace Import");