releng: ProjectExplorer tests stability improvement
[deliverable/tracecompass.git] / releng / org.eclipse.tracecompass.integration.swtbot.tests / src / org / eclipse / tracecompass / integration / swtbot / tests / projectexplorer / ProjectExplorerTracesFolderTest.java
CommitLineData
ab18f69a
MAL
1/******************************************************************************
2 * Copyright (c) 2016 Ericsson
3 *
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 *******************************************************************************/
9
10package org.eclipse.tracecompass.integration.swtbot.tests.projectexplorer;
11
12import static org.junit.Assert.assertEquals;
13import static org.junit.Assert.assertNotEquals;
14
15import java.io.File;
16import java.io.IOException;
17import java.util.List;
18import java.util.Set;
19import java.util.function.Supplier;
20
21import org.apache.log4j.Logger;
22import org.apache.log4j.varia.NullAppender;
23import org.eclipse.core.runtime.IPath;
24import org.eclipse.core.runtime.Path;
25import org.eclipse.jdt.annotation.NonNull;
26import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
27import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
28import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
29import org.eclipse.swtbot.swt.finder.SWTBot;
30import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
31import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
32import org.eclipse.swtbot.swt.finder.waits.Conditions;
33import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
34import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
d2fbf6b6 35import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
ab18f69a
MAL
36import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
37import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportConfirmation;
38import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportTraceWizardPage;
39import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition;
40import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition;
41import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
42import org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests.SWTBotImportWizardUtils;
43import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
44import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
f0beeb4a 45import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils;
ab18f69a 46import org.eclipse.ui.IPageLayout;
d7ac6294 47import org.junit.After;
ab18f69a
MAL
48import org.junit.AfterClass;
49import org.junit.BeforeClass;
50import org.junit.FixMethodOrder;
51import org.junit.Test;
52import org.junit.runner.RunWith;
53import org.junit.runners.MethodSorters;
54
55import com.google.common.collect.ImmutableList;
56import com.google.common.collect.ImmutableSet;
d2fbf6b6 57import com.google.common.collect.Lists;
ab18f69a
MAL
58
59/**
60 * SWTBot test for testing Project Explorer trace folders (context-menu,
61 * import, etc).
62 */
63@RunWith(SWTBotJunit4ClassRunner.class)
64@FixMethodOrder(MethodSorters.NAME_ASCENDING)
65@SuppressWarnings({"restriction", "javadoc"})
66public class ProjectExplorerTracesFolderTest {
67
d2fbf6b6
PT
68 private static final class ImportConfirmationSupplier implements Supplier<ImportConfirmation> {
69 List<ImportConfirmation> fConfirmations = Lists.newArrayList(ImportConfirmation.CONTINUE);
70
71 public ImportConfirmationSupplier(ImportConfirmation... confirmations) {
72 fConfirmations = Lists.newArrayList(confirmations);
73 }
74
75 @Override
76 public ImportConfirmation get() {
77 return fConfirmations.isEmpty() ? null : fConfirmations.remove(0);
78 }
79 }
80
ab18f69a
MAL
81 private static final String PROP_LAST_MODIFIED_PROPERTY = "last modified";
82 private static final String TEXT_EDITOR_ID = "org.eclipse.ui.DefaultTextEditor";
83
84 private static final String GENERIC_CTF_TRACE_TYPE = "Common Trace Format : Generic CTF Trace";
85 private static final String LTTNG_KERNEL_TRACE_TYPE = "Common Trace Format : Linux Kernel Trace";
86 private static final String LTTNG_UST_TRACE_TYPE = "Common Trace Format : LTTng UST Trace";
87 private static final String CUSTOM_TEXT_TRACE_TYPE = "Custom Text : TmfGeneric";
88 private static final String CUSTOM_XML_TRACE_TYPE = "Custom XML : Custom XML Log";
89
90 private static final @NonNull TestTraceInfo CUSTOM_TEXT_LOG = new TestTraceInfo("ExampleCustomTxt.log", CUSTOM_TEXT_TRACE_TYPE, 10, "29:52.034");
91 private static final @NonNull TestTraceInfo CUSTOM_XML_LOG = new TestTraceInfo("ExampleCustomXml.xml", CUSTOM_XML_TRACE_TYPE, 6, "22:01:20");
92 private static final @NonNull TestTraceInfo LTTNG_KERNEL_TRACE = new TestTraceInfo("kernel-overlap-testing", LTTNG_KERNEL_TRACE_TYPE, 1000, "04:32.650 993 664");
93 private static final @NonNull TestTraceInfo SIMPLE_SERVER1_UST_TRACE = new TestTraceInfo("simple_server-thread1", LTTNG_UST_TRACE_TYPE, 1000, "04:32.650 993 664");
94 private static final @NonNull TestTraceInfo SIMPLE_SERVER2_UST_TRACE = new TestTraceInfo("simple_server-thread2", LTTNG_UST_TRACE_TYPE, 1000, "04:32.650 993 664");
95 private static final @NonNull TestTraceInfo UST_OVERLAP_TESTING_UST_TRACE = new TestTraceInfo("ust-overlap-testing", LTTNG_UST_TRACE_TYPE, 1000, "04:32.650 993 664");
96
97 private static final String CLASHES_DIR_NAME = "z-clashes";
98 private static final @NonNull TestTraceInfo CLASHES_CUSTOM_TEXT_LOG = new TestTraceInfo("ExampleCustomTxt.log", CLASHES_DIR_NAME + "/ExampleCustomTxt.log", CUSTOM_TEXT_TRACE_TYPE, 11, "29:52.034");
99 private static final @NonNull TestTraceInfo CLASHES_CUSTOM_XML_LOG = new TestTraceInfo("ExampleCustomXml.xml", CLASHES_DIR_NAME + "/ExampleCustomXml.xml", CUSTOM_XML_TRACE_TYPE, 7, "22:01:20");
100 private static final @NonNull TestTraceInfo CLASHES_LTTNG_KERNEL_TRACE = new TestTraceInfo("kernel-overlap-testing", CLASHES_DIR_NAME + "/kernel-overlap-testing", LTTNG_KERNEL_TRACE_TYPE, 1001, "04:32.650 993 664");
101 private static final @NonNull TestTraceInfo CLASHES_SIMPLE_SERVER1_UST_TRACE = new TestTraceInfo("simple_server-thread1", CLASHES_DIR_NAME + "/simple_server-thread1", LTTNG_UST_TRACE_TYPE, 1001, "04:32.650 993 664");
102 private static final @NonNull TestTraceInfo CLASHES_SIMPLE_SERVER2_UST_TRACE = new TestTraceInfo("simple_server-thread2", CLASHES_DIR_NAME + "/simple_server-thread2", LTTNG_UST_TRACE_TYPE, 1001, "04:32.650 993 664");
103 private static final @NonNull TestTraceInfo CLASHES_UST_OVERLAP_TESTING_UST_TRACE = new TestTraceInfo("ust-overlap-testing", CLASHES_DIR_NAME + "/ust-overlap-testing", LTTNG_UST_TRACE_TYPE, 1001, "04:32.650 993 664");
104
105
106 private static final @NonNull TestTraceInfo LTTNG_KERNEL_TRACE_METADATA = new TestTraceInfo(LTTNG_KERNEL_TRACE.getTraceName(), LTTNG_KERNEL_TRACE.getTraceName() + "/metadata", LTTNG_KERNEL_TRACE.getTraceType(), LTTNG_KERNEL_TRACE.getNbEvents(),
107 LTTNG_KERNEL_TRACE.getFirstEventTimestamp());
108 private static final @NonNull TestTraceInfo UNRECOGNIZED_LOG = new TestTraceInfo("unrecognized.log", "", 0, "");
109 private static final @NonNull TestTraceInfo CUSTOM_XML_LOG_AS_TEXT = new TestTraceInfo("ExampleCustomXml.xml", CUSTOM_TEXT_TRACE_TYPE, 0, "");
cdfe10e7 110 private static final @NonNull TestTraceInfo CLASHES_CUSTOM_XML_LOG_AS_TEXT = new TestTraceInfo("ExampleCustomXml.xml", CLASHES_DIR_NAME + "/ExampleCustomXml.xml", CUSTOM_TEXT_TRACE_TYPE, 0, "");
ab18f69a
MAL
111
112 private static final TestTraceInfo[] ALL_TRACEINFOS = new TestTraceInfo[] {
113 CUSTOM_TEXT_LOG,
114 CUSTOM_XML_LOG,
115 LTTNG_KERNEL_TRACE,
116 SIMPLE_SERVER1_UST_TRACE,
117 SIMPLE_SERVER2_UST_TRACE,
118 UST_OVERLAP_TESTING_UST_TRACE,
119
120 CLASHES_CUSTOM_TEXT_LOG,
121 CLASHES_CUSTOM_XML_LOG,
122 CLASHES_LTTNG_KERNEL_TRACE,
123 CLASHES_SIMPLE_SERVER1_UST_TRACE,
124 CLASHES_SIMPLE_SERVER2_UST_TRACE,
125 CLASHES_UST_OVERLAP_TESTING_UST_TRACE
126 };
127
128 private static final Set<TestTraceInfo> CLASHING_TRACEINFOS = ImmutableSet.of(
129 CLASHES_CUSTOM_TEXT_LOG,
130 CLASHES_CUSTOM_XML_LOG,
131 CLASHES_LTTNG_KERNEL_TRACE,
132 CLASHES_SIMPLE_SERVER1_UST_TRACE,
133 CLASHES_SIMPLE_SERVER2_UST_TRACE,
134 CLASHES_UST_OVERLAP_TESTING_UST_TRACE);
135
136 // All normal traces plus the unrecognized trace
137 private static final int NUM_UNIQUE_TRACES = CLASHING_TRACEINFOS.size() + 1;
138
139
140 private static final File TEST_TRACES_PATH = new File(new Path(TmfTraceManager.getTemporaryDirPath()).append("testtraces").toOSString());
d2fbf6b6 141 private static final String DEFAULT_PROJECT_NAME = "Tracing";
ab18f69a
MAL
142 private static final String TRACE_PROJECT_NAME = "test";
143 private static final String MANAGE_CUSTOM_PARSERS_SHELL_TITLE = "Manage Custom Parsers";
144
145 private static SWTWorkbenchBot fBot;
146
147 /** The Log4j logger instance. */
148 private static final Logger fLogger = Logger.getRootLogger();
149
150 private static String getPath(String relativePath) {
151 return new Path(TEST_TRACES_PATH.getAbsolutePath()).append(relativePath).toOSString();
152 }
153
154 /**
155 * Test Class setup
156 *
157 * @throws IOException
158 */
159 @BeforeClass
160 public static void init() throws IOException {
161 TestDirectoryStructureUtil.generateTraceStructure(TEST_TRACES_PATH);
162
163 SWTBotUtils.initialize();
164
165 /* Set up for swtbot */
166 SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
167 SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
168 fLogger.removeAllAppenders();
169 fLogger.addAppender(new NullAppender());
170 fBot = new SWTWorkbenchBot();
171
172 SWTBotUtils.closeView("Welcome", fBot);
173
174 SWTBotUtils.switchToTracingPerspective();
175
176 /* Finish waiting for eclipse to load */
f0beeb4a 177 WaitUtils.waitForJobs();
ab18f69a 178 SWTBotUtils.createProject(TRACE_PROJECT_NAME);
e4af2e99 179 importCustomParsers();
ab18f69a
MAL
180 }
181
182 /**
183 * Test class tear down method.
184 */
185 @AfterClass
186 public static void tearDown() {
187 SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot);
d2fbf6b6 188 SWTBotUtils.deleteProject(DEFAULT_PROJECT_NAME, fBot);
ab18f69a
MAL
189 fLogger.removeAllAppenders();
190 }
191
d7ac6294
MAL
192 /**
193 * Test tear down method.
194 */
195 @After
196 public void afterTest() {
197 SWTBotUtils.closeSecondaryShells(fBot);
198 }
199
e4af2e99 200 private static void importCustomParsers() {
ab18f69a
MAL
201 // FIXME: We can't use Manage Custom Parsers > Import because it uses a native dialog. We'll still check that they show up in the dialog
202 CustomTxtTraceDefinition[] txtDefinitions = CustomTxtTraceDefinition.loadAll(getPath("customParsers/ExampleCustomTxtParser.xml"));
203 txtDefinitions[0].save();
204 CustomXmlTraceDefinition[] xmlDefinitions = CustomXmlTraceDefinition.loadAll(getPath("customParsers/ExampleCustomXmlParser.xml"));
205 xmlDefinitions[0].save();
206
207 SWTBotTreeItem traceFolder = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
208 traceFolder.contextMenu("Manage Custom Parsers...").click();
209 fBot.waitUntil(Conditions.shellIsActive(MANAGE_CUSTOM_PARSERS_SHELL_TITLE));
210 SWTBotShell shell = fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE);
211 SWTBot shellBot = shell.bot();
212
213 // Make sure the custom text trace type is imported
214 shellBot.list().select(CUSTOM_TEXT_LOG.getTraceType());
215
216 // Make sure the custom xml trace type is imported
217 shellBot.radio("XML").click();
218 shellBot.list().select(CUSTOM_XML_LOG.getTraceType());
219 shellBot.button("Close").click();
220 shellBot.waitUntil(Conditions.shellCloses(shell));
221 }
222
223 /**
224 * Test that the expected context menu items are there
225 * <p>
226 * Action : Trace Folder menu
227 * <p>
228 * Procedure :Select the Traces folder and open its context menu
229 * <p>
230 * Expected Results: Correct menu opens (Import, Refresh, etc)
231 */
232 @Test
233 public void test3_01ContextMenuPresence() {
ab18f69a
MAL
234 SWTBotTreeItem traceItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
235
236 final List<String> EXPECTED_MENU_LABELS = ImmutableList.of(
237 "Open Trace...",
238 "",
239 "Import...",
240 "",
241 "New Folder...",
242 "Clear",
243 "",
244 "Import Trace Package...",
245 "Fetch Remote Traces...",
246 "",
247 "Export Trace Package...",
248 "",
249 "Manage Custom Parsers...",
250 "Manage XML analyses...",
251 "",
252 "Apply Time Offset...",
253 "Clear Time Offset",
254 "",
255 "Refresh");
256
257 List<String> menuLabels = traceItem.contextMenu().menuItems();
258 for (int i = 0; i < menuLabels.size(); i++) {
259 assertEquals(EXPECTED_MENU_LABELS.get(i), menuLabels.get(i));
260 }
261
262 fBot.closeAllEditors();
263 }
264
265 /**
266 * Test that the trace import wizard appears
267 * <p>
268 * Action : Trace Import Wizard
269 * <p>
270 * Procedure : Select Import
271 * <p>
272 * Expected Results: Trace Import Wizard appears
273 */
274 @Test
275 public void test3_02Import() {
276 SWTBotTreeItem traceItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
277
278 SWTBotShell shell = openTraceFoldersImport(traceItem);
279 shell.bot().button("Cancel").click();
280 }
281
282 /**
283 * Test that the trace import wizard can import a single custom text trace
284 * <p>
285 * Action : Import single custom text trace (link to workspace)
286 * <p>
287 * <pre>
288 * Procedure : 1) Browse to directory ${local}/traces/import/
289 * 2) Select trace ExampleCustomTxt.log
290 * 3) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning" and select "Create Links to workspace" and
291 * 4) press Finish
292 * </pre>
293 * <p>
294 * Expected Results: Imported trace appear in Traces Folder and the Trace Type Tmf Generic is set. Make sure trace can be opened
295 */
296 @Test
297 public void test3_03SingleCustomTextTrace() {
298 int optionFlags = ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES | ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
299 testSingleTrace(CUSTOM_TEXT_LOG, optionFlags);
300 }
301
302 /**
303 * <p>
304 * Action : Import Single custom XML trace (link to workspace)
305 * <p>
306 *
307 * <pre>
308 * Procedure : redo 3.1-3.3 but this time select ExampleCustomXml.xml
309 * </pre>
310 * <p>
311 * Expected Results: Imported trace appear in Traces Folder and the Trace
312 * Type "Custom XML log" is set. Make sure that trace can be opened
313 */
314 @Test
315 public void test3_04SingleCustomXmlTrace() {
316 int optionFlags = ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES | ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
317 testSingleTrace(CUSTOM_XML_LOG, optionFlags);
318 }
319
320 /**
321 * <p>
322 * Action : Import LTTng Kernel CTF trace (link to workspace)
323 * <p>
324 *
325 * <pre>
326 * Procedure : redo 3.1-3.3 but this time select directory kernel-overlap-testing/
327 * </pre>
328 * <p>
329 * Expected Results: Imported trace appear in Traces Folder and the Trace
330 * Type "LTTng Kernel" is set. Make sure that trace can be opened
331 */
332 @Test
333 public void test3_05SingleCtfTrace() {
334 int optionFlags = ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES | ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
335 testSingleTrace(LTTNG_KERNEL_TRACE, optionFlags);
336 }
337
338 /**
339 * <p>
340 * Action : Rename + copy import
341 * <p>
342 *
343 * <pre>
344 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace"
345 * 2) When dialog box appear select Rename
346 * </pre>
347 * <p>
348 * Expected Results: Traces are imported with new name that has a suffix (2)
349 * at the end. Make sure that imported traces are copied to the project.
350 */
351 @Test
352 public void test3_06RenameCopyImport() {
353 testRenameCopyImport(CUSTOM_TEXT_LOG);
354 testRenameCopyImport(CUSTOM_XML_LOG);
355 testRenameCopyImport(LTTNG_KERNEL_TRACE);
356 }
357
358 private static void testRenameCopyImport(TestTraceInfo traceInfo) {
359 int optionFlags = ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES;
360 importTrace(optionFlags, ImportConfirmation.RENAME, traceInfo.getTraceName());
361 String renamed = toRenamedName(traceInfo.getTraceName());
362 verifyTrace(traceInfo, optionFlags, renamed);
363 }
364
365 /**
366 * <p>
367 * Action : Overwrite + copy import
368 * <p>
369 *
370 * <pre>
371 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace"
372 * 2) When dialog box appear select Overwrite
373 * </pre>
374 * <p>
375 * Expected Results: Existing traces are deleted and new traces are
376 * imported. Make sure that imported traces are copied to the project and
377 * can be opened
378 */
379 @Test
380 public void test3_07OverwriteCopyImport() {
381 testOverwriteCopyImport(CUSTOM_TEXT_LOG);
382 testOverwriteCopyImport(CUSTOM_XML_LOG);
383 testOverwriteCopyImport(LTTNG_KERNEL_TRACE);
384 }
385
386 private static void testOverwriteCopyImport(TestTraceInfo traceInfo) {
387 String traceName = traceInfo.getTraceName();
388 SWTBotTreeItem traceItem = SWTBotUtils.getTreeItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), traceName);
389 String lastModified = getTraceProperty(traceItem, PROP_LAST_MODIFIED_PROPERTY);
390 int optionFlags = ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES;
391 importTrace(optionFlags, ImportConfirmation.OVERWRITE, traceName);
392 verifyTrace(traceInfo, optionFlags);
393
394 assertNotEquals(lastModified, getTraceProperty(traceItem, PROP_LAST_MODIFIED_PROPERTY));
395 }
396
397 /**
398 * <p>
399 * Action : Skip
400 * <p>
401 *
402 * <pre>
403 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace"
404 * 2) When dialog box appear select Skip
405 * </pre>
406 * <p>
407 * Expected Results: Make sure that no new trace is imported
408 */
409 @Test
410 public void test3_08SkipImport() {
411 testSkipImport(CUSTOM_TEXT_LOG);
412 testSkipImport(CUSTOM_XML_LOG);
413 testSkipImport(LTTNG_KERNEL_TRACE);
414 }
415
416 private static void testSkipImport(TestTraceInfo traceInfo) {
417 String traceName = traceInfo.getTraceName();
418 SWTBotTreeItem traceItem = SWTBotUtils.getTreeItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), traceName);
419 String lastModified = getTraceProperty(traceItem, PROP_LAST_MODIFIED_PROPERTY);
420 int optionFlags = ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES;
421 importTrace(optionFlags, ImportConfirmation.SKIP, traceName);
422 verifyTrace(traceInfo, optionFlags);
423
424 assertEquals(lastModified, getTraceProperty(traceItem, PROP_LAST_MODIFIED_PROPERTY));
425 }
426
427 /**
428 * <p>
429 * Action : Default overwrite
430 * <p>
431 *
432 * <pre>
433 * Procedure : 1) redo 3.3, 3.4, 3.5. However, Unselect "Create Links to workspace" and select "Overwrite existing without warning"
434 * </pre>
435 * <p>
436 * Expected Results: Make sure that no dialog box appears (for renaming,
437 * overwriting, skipping) and existing traces are overwritten). Make sure
438 * trace can be opened
439 */
440 @Test
441 public void test3_09OverwriteOptionImport() {
442 testOverwriteOptionImport(CUSTOM_TEXT_LOG);
443 testOverwriteOptionImport(CUSTOM_XML_LOG);
444 testOverwriteOptionImport(LTTNG_KERNEL_TRACE);
445 }
446
447 private static void testOverwriteOptionImport(TestTraceInfo traceInfo) {
448 String traceName = traceInfo.getTraceName();
449 SWTBotTreeItem traceItem = SWTBotUtils.getTreeItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), traceName);
450 String lastModified = getTraceProperty(traceItem, PROP_LAST_MODIFIED_PROPERTY);
451
452 int optionFlags = ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES | ImportTraceWizardPage.OPTION_OVERWRITE_EXISTING_RESOURCES;
453 importTrace(optionFlags, ImportConfirmation.CONTINUE, traceName);
454 verifyTrace(traceInfo, optionFlags);
455
456 assertNotEquals(lastModified, getTraceProperty(traceItem, PROP_LAST_MODIFIED_PROPERTY));
457 }
458
459 /**
460 * <p>
461 * Action : Import unrecognized
462 * <p>
463 *
464 * <pre>
465 * Procedure : 1) Open Import wizard (see 3.1-3.2)
466 * 2) Browse to directory ${local}/traces/import
467 * 3) Select trace unrecognized.log
468 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning" and select "Create Links to workspace" and
469 * 5) press Finish
470 * </pre>
471 * <p>
472 * Expected Results: unrecognized.log is imported with trace type unknown.
473 * The default text file icon is displayed. The trace, when opened, is
474 * displayed in the text editor.
475 */
476 @Test
477 public void test3_10ImportUnrecognized() {
478 String traceName = UNRECOGNIZED_LOG.getTraceName();
479 int optionFlags = ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES | ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
480 importTrace(optionFlags, traceName);
481 verifyTrace(UNRECOGNIZED_LOG, optionFlags);
482 }
483
484 /**
485 * <p>
486 * Action : Import unrecognized (ignore)
487 * <p>
488 *
489 * <pre>
490 * Procedure : 1) redo 3.10, however unselect "Import unrecognized traces"
491 * </pre>
492 * <p>
493 * Expected Results: unrecognized.log is not imported
494 */
495 @Test
496 public void test3_11ImportUnrecognizedIgnore() {
497 String traceName = UNRECOGNIZED_LOG.getTraceName();
498 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
499 int numTraces = tracesFolderItem.getItems().length;
500
501 SWTBotTreeItem traceItem = SWTBotUtils.getTreeItem(fBot, tracesFolderItem, traceName);
502 String lastModified = getTraceProperty(traceItem, PROP_LAST_MODIFIED_PROPERTY);
503
504 int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
505 importTrace(optionFlags, traceName);
506 verifyTrace(UNRECOGNIZED_LOG, optionFlags);
507
508 assertEquals(lastModified, getTraceProperty(traceItem, PROP_LAST_MODIFIED_PROPERTY));
509 assertEquals(numTraces, tracesFolderItem.getItems().length);
510 }
511
512 /**
513 * <p>
514 * Action : Import CTF trace by selection metadata file only
515 * <p>
516 *
517 * <pre>
518 * Procedure : 1) Redo 3.5, However only select metadata file instead of directory trace
519 * </pre>
520 * <p>
521 * Expected Results: Imported trace appear in Traces Folder and the Trace
522 * Type "LTTng Kernel" is set. Make sure that trace can be opened
523 */
524 @Test
525 public void test3_12ImportCtfWithMetadataSelection() {
526 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
527 testSingleTrace(LTTNG_KERNEL_TRACE_METADATA, ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES | ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE);
528 }
529
530 /**
531 * <p>
532 * Action : Recursive import with auto-detection (Rename All)
533 * <p>
534 *
535 * <pre>
536 * Procedure : 1) Open Import wizard (see 3.1-3.2)
537 * 2) Browse to directory ${local}/traces/import
538 * 3) select directory import
539 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
540 * 5) press Finish
541 * 6) When dialog appears select "Rename All"
542 * </pre>
543 * <p>
544 * Expected Results: All Traces are imported with respective trace type set.
545 * Traces with name clashes are imported with suffix (2). 1 trace
546 * (unrecognized.log) is imported with trace type unknown. Make sure that
547 * traces can be opened which have a trace type set. The unknown trace type
548 * should open with the text editor.
549 */
550 @Test
551 public void test3_13ImportRecursiveAutoRenameAll() {
552 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
553
554 int optionFlags = ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES | ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
555 importTrace(optionFlags, ImportConfirmation.RENAME_ALL, "");
556
557 for (TestTraceInfo info : ALL_TRACEINFOS) {
558 String traceName = info.getTraceName();
559 if (CLASHING_TRACEINFOS.contains(info)) {
560 traceName = toRenamedName(traceName);
561 }
562 verifyTrace(info, optionFlags, traceName);
563 }
564
565 // Also check unrecognized file
566 verifyTrace(UNRECOGNIZED_LOG, optionFlags);
567 }
568
569 /**
570 * <p>
571 * Action : Recursive import with auto-detection (Overwrite All)
572 * <p>
573 *
574 * <pre>
575 * Procedure : 1) Open Import wizard (see 3.1-3.2)
576 * 2) Browse to directory ${local}/traces/import/
577 * 3) select directory import
578 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
579 * 5) press Finish
580 * 6) When dialog appears select Overwrite All"
581 * </pre>
582 * <p>
583 * Expected Results: All Traces are imported with respective trace type set.
584 * Traces with name clashes are overwritten . 1 trace (unrecognized.log) is
585 * imported with trace type unknown. Make sure that traces can be opened
586 * which have a trace type set. The unknown trace type should open with the
587 * text editor.
588 */
589 @Test
590 public void test3_14ImportRecursiveAutoOverwriteAll() {
591 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
592
593 int optionFlags = ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES | ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
594 importTrace(optionFlags, ImportConfirmation.OVERWRITE_ALL, "");
595
596 for (TestTraceInfo info : CLASHING_TRACEINFOS) {
597 verifyTrace(info, optionFlags);
598 }
599
600 // All traces should have clashed/overwritten (plus the unrecognized trace)
601 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
602 assertEquals(NUM_UNIQUE_TRACES, tracesFolderItem.getItems().length);
603
604 // Also check unrecognized file
605 verifyTrace(UNRECOGNIZED_LOG, optionFlags);
606 }
607
608 /**
609 * <p>
610 * Action : Recursive import with auto-detection (Skip All)
611 * <p>
612 *
613 * <pre>
614 * Procedure : 1) Open Import wizard (see 3.1-3.2)
615 * 2) Browse to directory ${local}/traces/import/
616 * 3) select directory import
617 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning" and select "Create Links to workspace" and uncheck "preserve folder structure"
618 * 5) press Finish
619 * 6) When dialog appears select Skip All"
620 * </pre>
621 * <p>
622 * Expected Results: All Traces are imported with respective trace type set. Traces with name
623 * clashes are not imported. 1 trace (unrecognized.log) is imported with
624 * trace type unknown. The unknown trace type should open with the text
625 * editor.
626 */
627 @Test
628 public void test3_15ImportRecursiveAutoSkipAll() {
629 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
630
631 int optionFlags = ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES | ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
632 importTrace(optionFlags, ImportConfirmation.SKIP_ALL, "");
633
634 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
635 for (TestTraceInfo info : ALL_TRACEINFOS) {
636 if (!CLASHING_TRACEINFOS.contains(info)) {
637 verifyTrace(info, optionFlags);
638 }
639 }
640
641 // All traces should have skipped (plus the unrecognized trace)
642 assertEquals(NUM_UNIQUE_TRACES, tracesFolderItem.getItems().length);
643
644 // Also check unrecognized file
645 verifyTrace(UNRECOGNIZED_LOG, optionFlags);
646 }
647
648 /**
649 * <p>
650 * Action : Recursive import with auto-detection (test rename, overwrite and
651 * skip)
652 * <p>
653 *
654 * <pre>
655 * Procedure : 1) Open Import wizard (see 3.1-3.2)
656 * 2) Browse to directory ${local}/traces/import/
657 * 3) select directory import
658 * 4) Keep <Auto Detection>, Select "Import unrecognized traces", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
659 * 5) press Finish
660 * 6) When dialog appears select "Rename"
661 * 7) When dialog appears select "Overwrite"
662 * 8) When dialog appears select "Skip"
663 * </pre>
664 * <p>
665 * Expected Results: All Traces are imported with respective trace type set. Traces with name
666 * clashes are either renamed, overwritten or skipped as per dialog action.
667 * Make sure that traces can be opened which have trace type set. The
668 * unknown trace type should open with the text editor.
669 */
670 @Test
671 public void test3_16ImportRecursiveAutoRenameOverwriteSkip() {
672 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
673
d2fbf6b6
PT
674 Supplier<ImportConfirmation> confirmationSupplier = new ImportConfirmationSupplier(
675 ImportConfirmation.RENAME, ImportConfirmation.OVERWRITE, ImportConfirmation.SKIP);
ab18f69a
MAL
676 int optionFlags = ImportTraceWizardPage.OPTION_IMPORT_UNRECOGNIZED_TRACES | ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
677 importTrace(optionFlags, confirmationSupplier, LTTNG_KERNEL_TRACE.getTracePath(), CLASHES_LTTNG_KERNEL_TRACE.getTracePath(), SIMPLE_SERVER1_UST_TRACE.getTracePath(), CLASHES_SIMPLE_SERVER1_UST_TRACE.getTracePath(),
678 SIMPLE_SERVER2_UST_TRACE.getTracePath(), CLASHES_SIMPLE_SERVER2_UST_TRACE.getTracePath(), UNRECOGNIZED_LOG.getTracePath());
679
680 verifyTrace(LTTNG_KERNEL_TRACE, optionFlags);
681
682 // Renamed trace
683 String renamed = toRenamedName(CLASHES_LTTNG_KERNEL_TRACE.getTraceName());
684 verifyTrace(CLASHES_LTTNG_KERNEL_TRACE, optionFlags, renamed);
685
686 // Overwritten trace
687 verifyTrace(CLASHES_SIMPLE_SERVER1_UST_TRACE, optionFlags);
688
689 // Skipped trace
690 verifyTrace(SIMPLE_SERVER2_UST_TRACE, optionFlags);
691
692 // Also check unrecognized file
693 verifyTrace(UNRECOGNIZED_LOG, optionFlags);
694 }
695
696 /**
697 * <p>
698 * Action : Recursive import with specific trace type 1 (Skip All) skip)
699 * <p>
700 *
701 * <pre>
702 * Procedure : 1) Open Import wizard
703 * 2) Browse to directory ${local}/traces/import/
704 * 3) Select directory import
705 * 4) Select trace type "Generic CTF Trace", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"and
706 * 5) press Finish
707 * 6) When dialog appears select Skip All"
708 * </pre>
709 * <p>
710 * Expected Results: After selecting trace type, verify that button "Import
711 * unrecognized traces" is disabled. 4 CTF traces are imported with trace
712 * type "Generic CTF Trace" . Make sure that these traces can be opened
713 */
714 @Test
cdfe10e7 715 public void test3_17ImportRecursiveSpecifyTraceTypeCTF() {
ab18f69a
MAL
716 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
717
718 int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
719 importTrace(GENERIC_CTF_TRACE_TYPE, optionFlags, ImportConfirmation.SKIP_ALL, "");
720
721 final TestTraceInfo[] CTF_TRACEINFOS = new TestTraceInfo[] {
722 LTTNG_KERNEL_TRACE,
723 SIMPLE_SERVER1_UST_TRACE,
724 SIMPLE_SERVER2_UST_TRACE,
725 UST_OVERLAP_TESTING_UST_TRACE
726 };
727 for (TestTraceInfo info : CTF_TRACEINFOS) {
728 verifyTrace(info, optionFlags, info.getTraceName(), GENERIC_CTF_TRACE_TYPE);
729 }
730
731 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
732 assertEquals(CTF_TRACEINFOS.length, tracesFolderItem.getItems().length);
733 }
734
735 /**
736 * <p>
737 * Action : Recursive import with specific trace type 2 (Skip All)
738 * <p>
739 *
740 * <pre>
741 * Procedure : 1) Open Import wizard (see 3.1-3.2)
742 * 2) Browse to directory ${local}/traces/import/
743 * 3) Select directory import
744 * 4) Select trace type "LTTng Kernel Trace", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
745 * 5) Press Finish
746 * 6) When dialog appears select Skip All"
747 * </pre>
748 * <p>
749 * Expected Results: After selecting trace type, verify that button "Import
750 * unrecognized traces" is disabled. One LTTng Kernel trace is imported with
751 * trace type "LTTng Kernel Trace". Make sure that this trace can be opened.
752 */
753 @Test
cdfe10e7 754 public void test3_18ImportRecursiveSpecifyTraceTypeKernel() {
ab18f69a
MAL
755 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
756
757 int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
758 importTrace(LTTNG_KERNEL_TRACE_TYPE, optionFlags, ImportConfirmation.SKIP_ALL, "");
759
760 verifyTrace(LTTNG_KERNEL_TRACE, optionFlags);
761
762 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
763 assertEquals(1, tracesFolderItem.getItems().length);
764 }
765
766 /**
767 * <p>
768 * Action : Recursive import with specific trace type 3 (Skip All)
769 * <p>
770 *
771 * <pre>
772 * Procedure : 1) Open Import wizard
773 * 2) Browse to directory ${local}/traces/import/
774 * 3) Select directory import
775 * 4) Select trace type "LTTng UST Trace", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
776 * 5) Press Finish
777 * 6) When dialog appears select Skip All"
778 * </pre>
779 * <p>
780 * Expected Results: After selecting trace type, verify that button "Import
781 * unrecognized traces" is disabled. 3 LTTng UST traces are imported with
782 * trace type "LTTng UST Trace". Make sure that these traces can be opened.
783 */
784 @Test
cdfe10e7 785 public void test3_19ImportRecursiveSpecifyTraceTypeUST() {
ab18f69a
MAL
786 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
787
788 int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
789 importTrace(LTTNG_UST_TRACE_TYPE, optionFlags, ImportConfirmation.SKIP_ALL, "");
790
791 final TestTraceInfo[] UST_TRACEINFOS = new TestTraceInfo[] {
792 SIMPLE_SERVER1_UST_TRACE,
793 SIMPLE_SERVER2_UST_TRACE,
794 UST_OVERLAP_TESTING_UST_TRACE
795 };
796 for (TestTraceInfo info : UST_TRACEINFOS) {
797 verifyTrace(info, optionFlags);
798 }
799
800 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
801 assertEquals(UST_TRACEINFOS.length, tracesFolderItem.getItems().length);
802 }
803
804 /**
805 * <p>
806 * Action : Recursive import with specific trace type 4 (Skip All)
807 * <p>
808 *
809 * <pre>
810 * Procedure : 1) Open Import wizard (see 3.1-3.2)
811 * 2) Browse to directory ${local}/traces/import/
812 * 3) select directory import
813 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and unselect "Preserve Folder Structure"
814 * 5) press Finish
815 * 6) When dialog appears select Skip All"
816 * </pre>
817 * <p>
818 * Expected Results: All text files in directories are imported as trace and
819 * trace type "Tmf Generic" is set. Note that trace type validation only
820 * checks for file exists and that file is not a directory. Make sure that
821 * these traces can be opened. However traces with wrong trace type won't
822 * show any events in the table.
823 */
824 @Test
cdfe10e7 825 public void test3_20ImportRecursiveSpecifyTraceTypeCustomText() {
ab18f69a
MAL
826 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
827
828 int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
829 importTrace(CUSTOM_TEXT_TRACE_TYPE, optionFlags, ImportConfirmation.SKIP_ALL, "");
830 verifyTrace(CUSTOM_TEXT_LOG, optionFlags);
831
832 final TestTraceInfo[] TEXT_BASED_TRACEINFOS = new TestTraceInfo[] {
833 CUSTOM_TEXT_LOG,
834 CUSTOM_XML_LOG_AS_TEXT,
835 UNRECOGNIZED_LOG
836 };
837 for (TestTraceInfo info : TEXT_BASED_TRACEINFOS) {
838 verifyTrace(info, optionFlags, info.getTraceName(), CUSTOM_TEXT_TRACE_TYPE);
839 }
840
841 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
842 assertEquals(TEXT_BASED_TRACEINFOS.length, tracesFolderItem.getItems().length);
843 }
844
d2fbf6b6
PT
845 /**
846 * Action : Test the import wizard from workbench menu with project selected
847 * <p>
848 * <pre>
849 * Procedure : 1) Select Project "Test" in Project Explorer view
850 * 2) Open import wizard from menu File > Import... > Tracing > Trace Import
851 * 3) Browse to directory ${local}/traces/import/
852 * 4) Select trace ExampleCustomTxt.log
853 * 5) Keep <Auto Detection>, select "Create Links to workspace" and
854 * 6) press Finish
855 * </pre>
856 * <p>
857 * Expected Results: Verify that trace is imported to "Test" project and can be opened.
858 */
859 @Test
860 public void test3_21ImportFromMenuProjectSelected() {
861 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
862
863 SWTBotUtils.selectProject(fBot, TRACE_PROJECT_NAME);
864 SWTBotShell shell = openWorkbenchMenuImport();
865 int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
866 importTrace(shell, null, null, optionFlags, new ImportConfirmationSupplier(), CUSTOM_TEXT_LOG.getTracePath());
867 verifyTrace(CUSTOM_TEXT_LOG, optionFlags);
868 }
869
870 /**
871 * Action : Test the import wizard from workbench menu with no project selected
872 * <p>
873 * <pre>
874 * Procedure : 1) Clear selection in Project Explorer view
875 * 2) Open import wizard from menu File > Import... > Tracing > Trace Import
876 * 3) Browse to directory ${local}/traces/import/
877 * 4) Select trace ExampleCustomTxt.log
878 * 5) Keep <Auto Detection>, select "Create Links to workspace" and
879 * 6) press Finish
880 * </pre>
881 * <p>
882 * Expected Results: Verify that trace is imported to default "Tracing" project and can be opened.
883 */
884 @Test
885 public void test3_22ImportFromMenuProjectNotSelected() {
886 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
887
888 SWTBotView projectExplorerBot = fBot.viewByTitle("Project Explorer");
889 projectExplorerBot.show();
890 projectExplorerBot.bot().waitUntil(Conditions.widgetIsEnabled(projectExplorerBot.bot().tree()));
891 projectExplorerBot.bot().tree().unselect();
892 SWTBotShell shell = openWorkbenchMenuImport();
893 int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
894 importTrace(shell, null, null, optionFlags, new ImportConfirmationSupplier(), CUSTOM_TEXT_LOG.getTracePath());
895 verifyTrace(CUSTOM_TEXT_LOG, optionFlags, CUSTOM_TEXT_LOG.getTraceName(), CUSTOM_TEXT_LOG.getTraceType(), DEFAULT_PROJECT_NAME);
896 SWTBotUtils.deleteProject(DEFAULT_PROJECT_NAME, fBot);
ab18f69a
MAL
897 }
898
cdfe10e7
PT
899 /**
900 * <p>
901 * Action : Recursive import with preserved folder structure
902 * <p>
903 *
904 * <pre>
905 * Procedure : 0) Delete all traces in project
906 * 1) Open Import wizard
907 * 2) Browse to directory ${local}/traces/import/
908 * 3) Select directory import
909 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and select "Preserve Folder Structure"
910 * 5) press Finish
911 * </pre>
912 * <p>
913 * Expected Results: All matching traces are imported with trace type set.
914 * The folder "clashes" is imported with traces inside. Make sure that the
915 * traces can be opened.
916 */
917 @Test
918 public void test3_29ImportRecursivePreserve() {
919 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
920
921 int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE | ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE;
922 importTrace(CUSTOM_TEXT_TRACE_TYPE, optionFlags, ImportConfirmation.CONTINUE, "");
923
924 verifyTrace(CUSTOM_TEXT_LOG, optionFlags, CUSTOM_TEXT_LOG.getTraceName(), CUSTOM_TEXT_TRACE_TYPE);
925 verifyTrace(CUSTOM_XML_LOG_AS_TEXT, optionFlags, CUSTOM_XML_LOG_AS_TEXT.getTraceName(), CUSTOM_TEXT_TRACE_TYPE);
926 verifyTrace(UNRECOGNIZED_LOG, optionFlags, UNRECOGNIZED_LOG.getTraceName(), CUSTOM_TEXT_TRACE_TYPE);
927 verifyTrace(CLASHES_CUSTOM_TEXT_LOG, optionFlags, CLASHES_CUSTOM_TEXT_LOG.getTracePath(), CUSTOM_TEXT_TRACE_TYPE);
928 verifyTrace(CLASHES_CUSTOM_XML_LOG_AS_TEXT, optionFlags, CLASHES_CUSTOM_XML_LOG_AS_TEXT.getTracePath(), CUSTOM_TEXT_TRACE_TYPE);
929
930 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
931 assertEquals(4, tracesFolderItem.getItems().length);
932 SWTBotTreeItem clashesFolderItem = SWTBotUtils.getTraceProjectItem(fBot, tracesFolderItem, CLASHES_DIR_NAME);
933 assertEquals(2, clashesFolderItem.getItems().length);
934 }
935
936 /**
937 * <p>
938 * Action : Recursive import with preserved folder structure (Skip All)
939 * <p>
940 *
941 * <pre>
942 * Procedure : 1) Open Import wizard
943 * 2) Browse to directory ${local}/traces/import/
944 * 3) Select directory import
945 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and select "Preserve Folder Structure"
946 * 5) press Finish
947 * 6) When dialog appears select "Skip All"
948 * </pre>
949 * <p>
950 * Expected Results: The wizard should finish quickly as no trace will be
951 * imported. Make sure that the traces can be opened.
952 */
953 @Test
954 public void test3_30ImportRecursivePreserveSkipAll() {
955 int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE | ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE;
956 importTrace(CUSTOM_TEXT_TRACE_TYPE, optionFlags, ImportConfirmation.SKIP_ALL, "");
957
958 verifyTrace(CUSTOM_TEXT_LOG, optionFlags, CUSTOM_TEXT_LOG.getTraceName(), CUSTOM_TEXT_TRACE_TYPE);
959 verifyTrace(CUSTOM_XML_LOG_AS_TEXT, optionFlags, CUSTOM_XML_LOG_AS_TEXT.getTraceName(), CUSTOM_TEXT_TRACE_TYPE);
960 verifyTrace(UNRECOGNIZED_LOG, optionFlags, UNRECOGNIZED_LOG.getTraceName(), CUSTOM_TEXT_TRACE_TYPE);
961 verifyTrace(CLASHES_CUSTOM_TEXT_LOG, optionFlags, CLASHES_CUSTOM_TEXT_LOG.getTracePath(), CUSTOM_TEXT_TRACE_TYPE);
962 verifyTrace(CLASHES_CUSTOM_XML_LOG_AS_TEXT, optionFlags, CLASHES_CUSTOM_XML_LOG_AS_TEXT.getTracePath(), CUSTOM_TEXT_TRACE_TYPE);
963
964 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
965 assertEquals(4, tracesFolderItem.getItems().length);
966 SWTBotTreeItem clashesFolderItem = SWTBotUtils.getTraceProjectItem(fBot, tracesFolderItem, CLASHES_DIR_NAME);
967 assertEquals(2, clashesFolderItem.getItems().length);
968 //TOOD: verify that traces were actually skipped
969 }
970
971 /**
972 * <p>
973 * Action : Recursive import with preserved folder structure (Rename All)
974 * <p>
975 *
976 * <pre>
977 * Procedure : 1) Open Import wizard
978 * 2) Browse to directory ${local}/traces/import/
979 * 3) Select directory import
980 * 4) Select trace type "Tmf Generic", unselect "Overwrite existing without warning", select "Create Links to workspace" and select "Preserve Folder Structure"
981 * 5) press Finish
982 * 6) When dialog appears select "Rename All"
983 * </pre>
984 * <p>
985 * Expected Results: All matching traces are imported with trace type set.
986 * The traces are renamed with suffix (2). The folder "clashes" is imported
987 * with traces inside. Make sure that the traces can be opened.
988 */
989 @Test
990 public void test3_31ImportRecursivePreserveRenameAll() {
991 int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE | ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE;
992 importTrace(CUSTOM_TEXT_TRACE_TYPE, optionFlags, ImportConfirmation.RENAME_ALL, "");
993
994 verifyTrace(CUSTOM_TEXT_LOG, optionFlags, toRenamedName(CUSTOM_TEXT_LOG.getTraceName()), CUSTOM_TEXT_TRACE_TYPE);
995 verifyTrace(CUSTOM_XML_LOG_AS_TEXT, optionFlags, toRenamedName(CUSTOM_XML_LOG_AS_TEXT.getTraceName()), CUSTOM_TEXT_TRACE_TYPE);
996 verifyTrace(UNRECOGNIZED_LOG, optionFlags, toRenamedName(UNRECOGNIZED_LOG.getTraceName()), CUSTOM_TEXT_TRACE_TYPE);
997 verifyTrace(CLASHES_CUSTOM_TEXT_LOG, optionFlags, toRenamedName(CLASHES_CUSTOM_TEXT_LOG.getTracePath()), CUSTOM_TEXT_TRACE_TYPE);
998 verifyTrace(CLASHES_CUSTOM_XML_LOG_AS_TEXT, optionFlags, toRenamedName(CLASHES_CUSTOM_XML_LOG_AS_TEXT.getTracePath()), CUSTOM_TEXT_TRACE_TYPE);
999
1000 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
1001 assertEquals(7, tracesFolderItem.getItems().length);
1002 SWTBotTreeItem clashesFolderItem = SWTBotUtils.getTraceProjectItem(fBot, tracesFolderItem, CLASHES_DIR_NAME);
1003 assertEquals(4, clashesFolderItem.getItems().length);
1004 }
1005
d2fbf6b6
PT
1006 /**
1007 * <p>
1008 * Action : Delete with mixed selection of traces and folder
1009 * <p>
1010 *
1011 * <pre>
1012 * Procedure : 0) Delete all traces in project
1013 * 1) Create two trace folders under the "Traces" folder
1014 * 2) Import 2 traces under each folder
1015 * 3) Open all 4 traces.
1016 * 4) Select the trace in the first folder and the second folder in the Project Explorer view
1017 * 5) Right-click, Delete. Click Yes.
1018 * </pre>
1019 * <p>
1020 * Expected Results: A dialog should ask the user to confirm deletion of the
1021 * selected elements. Clicking OK should remove all that was selected. The
1022 * editor of the 3 deleted traces should be closed automatically with one
1023 * remaining editor opened.
1024 */
1025 @Test
1026 public void test3_32DeleteTraceAndFolder() {
1027 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
1028
1029 SWTBotTreeItem tracesFolder = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
1030 tracesFolder.contextMenu().menu("New Folder...").click();
1031 SWTBot newFolderShellBot = fBot.shell("New Folder").bot();
1032 newFolderShellBot.text().setText("FolderA");
1033 newFolderShellBot.button("OK").click();
1034 tracesFolder.contextMenu().menu("New Folder...").click();
1035 newFolderShellBot = fBot.shell("New Folder").bot();
1036 newFolderShellBot.text().setText("FolderB");
1037 newFolderShellBot.button("OK").click();
1038
1039 int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
1040 SWTBotTreeItem traceFolder = SWTBotUtils.getTraceProjectItem(fBot, tracesFolder, "FolderA");
1041 SWTBotShell shell = openTraceFoldersImport(traceFolder);
1042 importTrace(shell, null, null, optionFlags, new ImportConfirmationSupplier(), CUSTOM_TEXT_LOG.getTracePath(), LTTNG_KERNEL_TRACE.getTracePath());
1043 verifyTrace(CUSTOM_TEXT_LOG, optionFlags, "FolderA/" + CUSTOM_TEXT_LOG.getTraceName(), CUSTOM_TEXT_TRACE_TYPE);
1044 verifyTrace(LTTNG_KERNEL_TRACE, optionFlags, "FolderA/" + LTTNG_KERNEL_TRACE.getTraceName(), LTTNG_KERNEL_TRACE_TYPE);
1045
1046 traceFolder = SWTBotUtils.getTraceProjectItem(fBot, tracesFolder, "FolderB");
1047 shell = openTraceFoldersImport(traceFolder);
1048 importTrace(shell, null, null, optionFlags, new ImportConfirmationSupplier(), CUSTOM_TEXT_LOG.getTracePath(), LTTNG_KERNEL_TRACE.getTracePath());
1049 verifyTrace(CUSTOM_TEXT_LOG, optionFlags, "FolderB/" + CUSTOM_TEXT_LOG.getTraceName(), CUSTOM_TEXT_TRACE_TYPE);
1050 verifyTrace(LTTNG_KERNEL_TRACE, optionFlags, "FolderB/" + LTTNG_KERNEL_TRACE.getTraceName(), LTTNG_KERNEL_TRACE_TYPE);
1051
1052 SWTBotTree tree = fBot.viewByTitle("Project Explorer").bot().tree();
1053 SWTBotTreeItem folderAItem = SWTBotUtils.getTraceProjectItem(fBot, tracesFolder, "FolderA");
1054 SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, folderAItem, CUSTOM_TEXT_LOG.getTraceName());
1055 SWTBotTreeItem folderBItem = SWTBotUtils.getTraceProjectItem(fBot, tracesFolder, "FolderB");
1056 tree.select(traceItem, folderBItem);
1057 tree.contextMenu().menu("Delete").click();
1058 SWTBot deleteConfirmationShellBot = fBot.shell("Confirm Delete").bot();
1059 deleteConfirmationShellBot.button("Yes").click();
1060 fBot.waitWhile(ConditionHelpers.isEditorOpened(fBot, "FolderA/" + CUSTOM_TEXT_LOG.getTraceName()));
1061 fBot.waitWhile(ConditionHelpers.isEditorOpened(fBot, "FolderB/" + CUSTOM_TEXT_LOG.getTraceName()));
1062 fBot.waitWhile(ConditionHelpers.isEditorOpened(fBot, "FolderB/" + LTTNG_KERNEL_TRACE.getTraceName()));
1063 fBot.waitUntil(ConditionHelpers.isEditorOpened(fBot, "FolderA/" + LTTNG_KERNEL_TRACE.getTraceName()));
1064 assertEquals(1, tracesFolder.getNodes().size());
1065 assertEquals(1, folderAItem.getNodes().size());
1066 }
1067
1068 /**
1069 * <p>
1070 * Action : Delete with multiple folders
1071 * <p>
1072 *
1073 * <pre>
1074 * Procedure : 0) Delete all traces in project
1075 * 1) Create two trace folders under the "Traces" folder
1076 * 2) Import a trace under each folder
1077 * 3) Open both traces.
1078 * 4) Select both folders in the Project Explorer view
1079 * 5) Right-click, Delete. Click Yes.
1080 * </pre>
1081 * <p>
1082 * Expected Results: A dialog should ask the user to confirm deletion of the
1083 * selected elements. Clicking OK should remove all that was selected. The
1084 * editor of the 3 deleted traces should be closed automatically with one
1085 * remaining editor opened.
1086 */
1087 @Test
1088 public void test3_33DeleteMultipleFolders() {
1089 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
1090
1091 SWTBotTreeItem tracesFolder = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
1092 tracesFolder.contextMenu().menu("New Folder...").click();
1093 SWTBot newFolderShellBot = fBot.shell("New Folder").bot();
1094 newFolderShellBot.text().setText("FolderA");
1095 newFolderShellBot.button("OK").click();
1096 tracesFolder.contextMenu().menu("New Folder...").click();
1097 newFolderShellBot = fBot.shell("New Folder").bot();
1098 newFolderShellBot.text().setText("FolderB");
1099 newFolderShellBot.button("OK").click();
1100
1101 int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
1102 SWTBotTreeItem traceFolder = SWTBotUtils.getTraceProjectItem(fBot, tracesFolder, "FolderA");
1103 SWTBotShell shell = openTraceFoldersImport(traceFolder);
1104 importTrace(shell, null, null, optionFlags, new ImportConfirmationSupplier(), CUSTOM_TEXT_LOG.getTracePath());
1105 verifyTrace(CUSTOM_TEXT_LOG, optionFlags, "FolderA/" + CUSTOM_TEXT_LOG.getTraceName(), CUSTOM_TEXT_TRACE_TYPE);
1106
1107 traceFolder = SWTBotUtils.getTraceProjectItem(fBot, tracesFolder, "FolderB");
1108 shell = openTraceFoldersImport(traceFolder);
1109 importTrace(shell, null, null, optionFlags, new ImportConfirmationSupplier(), LTTNG_KERNEL_TRACE.getTracePath());
1110 verifyTrace(LTTNG_KERNEL_TRACE, optionFlags, "FolderB/" + LTTNG_KERNEL_TRACE.getTraceName(), LTTNG_KERNEL_TRACE_TYPE);
1111
1112 SWTBotTree tree = fBot.viewByTitle("Project Explorer").bot().tree();
1113 SWTBotTreeItem folderAItem = SWTBotUtils.getTraceProjectItem(fBot, tracesFolder, "FolderA");
1114 SWTBotTreeItem folderBItem = SWTBotUtils.getTraceProjectItem(fBot, tracesFolder, "FolderB");
1115 tree.select(folderAItem, folderBItem);
1116 tree.contextMenu().menu("Delete").click();
1117 SWTBot deleteConfirmationShellBot = fBot.shell("Confirm Delete").bot();
1118 deleteConfirmationShellBot.button("Yes").click();
1119 fBot.waitWhile(ConditionHelpers.isEditorOpened(fBot, "FolderA/" + CUSTOM_TEXT_LOG.getTraceName()));
1120 fBot.waitWhile(ConditionHelpers.isEditorOpened(fBot, "FolderB/" + LTTNG_KERNEL_TRACE.getTraceName()));
1121 assertEquals(0, tracesFolder.getNodes().size());
1122 }
1123
1124 /**
1125 * <p>
1126 * Action : Clear single Traces folder
1127 * <p>
1128 *
1129 * <pre>
1130 * Procedure : 1) Import 2 traces from different folders preserving folder structure
1131 * 2) Open both traces.
1132 * 3) Select the Traces folder
1133 * 4) Right-click, Clear. Click Yes.
1134 * </pre>
1135 * <p>
1136 * Expected Results: A dialog should ask the user to confirm clearing of the
1137 * folder. Clicking Yes should remove everything under the selected folder
1138 * and close the traces.
1139 */
1140 @Test
1141 public void test3_34ClearSingleTracesFolder() {
1142 int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE | ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE;
1143 importTrace(CUSTOM_TEXT_TRACE_TYPE, optionFlags, ImportConfirmation.CONTINUE, CUSTOM_TEXT_LOG.getTraceName(), CLASHES_CUSTOM_TEXT_LOG.getTracePath());
1144
1145 verifyTrace(CUSTOM_TEXT_LOG, optionFlags, CUSTOM_TEXT_LOG.getTraceName(), CUSTOM_TEXT_TRACE_TYPE);
1146 verifyTrace(CLASHES_CUSTOM_TEXT_LOG, optionFlags, CLASHES_CUSTOM_TEXT_LOG.getTracePath(), CUSTOM_TEXT_TRACE_TYPE);
1147
1148 SWTBotTreeItem tracesFolder = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
1149 tracesFolder.contextMenu().menu("Clear").click();
1150 SWTBot deleteConfirmationShellBot = fBot.shell("Confirm Clear").bot();
1151 deleteConfirmationShellBot.button("Yes").click();
1152 fBot.waitWhile(ConditionHelpers.isEditorOpened(fBot, CUSTOM_TEXT_LOG.getTraceName()));
1153 fBot.waitWhile(ConditionHelpers.isEditorOpened(fBot, CLASHES_CUSTOM_TEXT_LOG.getTracePath()));
1154 assertEquals(0, tracesFolder.getNodes().size());
1155 }
1156
1157 /**
1158 * <p>
1159 * Action : Clear multiple Traces folder
1160 * <p>
1161 *
1162 * <pre>
1163 * Procedure : 1) Import 2 traces to different projects
1164 * 2) Open both traces.
1165 * 3) Select both Traces folders
1166 * 4) Right-click, Clear. Click Yes.
1167 * </pre>
1168 * <p>
1169 * Expected Results: A dialog should ask the user to confirm clearing of the
1170 * folders. Clicking Yes should remove everything under the selected folders
1171 * and close the traces.
1172 */
1173 @Test
1174 public void test3_35ClearMultipleTracesFolder() {
1175 int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
1176 SWTBotTreeItem tracesFolder1 = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
1177 SWTBotShell shell = openTraceFoldersImport(tracesFolder1);
1178 importTrace(shell, null, null, optionFlags, new ImportConfirmationSupplier(), CUSTOM_TEXT_LOG.getTracePath());
1179 verifyTrace(CUSTOM_TEXT_LOG, optionFlags, CUSTOM_TEXT_LOG.getTraceName(), CUSTOM_TEXT_TRACE_TYPE, TRACE_PROJECT_NAME);
1180
1181 SWTBotUtils.createProject(DEFAULT_PROJECT_NAME);
1182 SWTBotTreeItem tracesFolder2 = SWTBotUtils.selectTracesFolder(fBot, DEFAULT_PROJECT_NAME);
1183 shell = openTraceFoldersImport(tracesFolder2);
1184 importTrace(shell, null, null, optionFlags, new ImportConfirmationSupplier(), LTTNG_KERNEL_TRACE.getTracePath());
1185 verifyTrace(LTTNG_KERNEL_TRACE, optionFlags, LTTNG_KERNEL_TRACE.getTraceName(), LTTNG_KERNEL_TRACE_TYPE, DEFAULT_PROJECT_NAME);
1186
1187 SWTBotTree tree = fBot.viewByTitle("Project Explorer").bot().tree();
1188 tree.select(tracesFolder1, tracesFolder2);
1189 tree.contextMenu().menu("Clear").click();
1190 SWTBot deleteConfirmationShellBot = fBot.shell("Confirm Clear").bot();
1191 deleteConfirmationShellBot.button("Yes").click();
1192 fBot.waitWhile(ConditionHelpers.isEditorOpened(fBot, CUSTOM_TEXT_LOG.getTraceName()));
1193 fBot.waitWhile(ConditionHelpers.isEditorOpened(fBot, LTTNG_KERNEL_TRACE.getTraceName()));
1194 assertEquals(0, tracesFolder1.getNodes().size());
1195 assertEquals(0, tracesFolder2.getNodes().size());
1196
1197 SWTBotUtils.deleteProject(DEFAULT_PROJECT_NAME, fBot);
1198 }
1199
cdfe10e7
PT
1200 /**
1201 * <p>
1202 * Action : Import from zip archive with preserved folder structure
1203 * <p>
1204 *
1205 * <pre>
1206 * Procedure : 0) Delete all traces in project
1207 * 1) Open Import wizard
1208 * 2) Select archive file: traces.zip
1209 * 3) Select archive root directory
1210 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
1211 * 5) press Finish
1212 * </pre>
1213 * <p>
1214 * Expected Results: All traces are imported with trace type set. The folder
1215 * "clashes" is imported with traces inside. Make sure that the traces can
1216 * be opened.
1217 */
1218 @Test
1219 public void test3_36ImportZipArchivePreserve() {
1220 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
1221
1222 int optionFlags = ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE;
1223 importTrace("traces.zip", null, optionFlags, ImportConfirmation.CONTINUE, "");
1224
1225 for (TestTraceInfo info : ALL_TRACEINFOS) {
1226 verifyTrace(info, optionFlags, info.getTracePath());
1227 }
1228
1229 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
1230 assertEquals(7, tracesFolderItem.getItems().length);
1231 SWTBotTreeItem clashesFolderItem = SWTBotUtils.getTraceProjectItem(fBot, tracesFolderItem, CLASHES_DIR_NAME);
1232 assertEquals(6, clashesFolderItem.getItems().length);
1233 }
1234
1235 /**
1236 * <p>
1237 * Action : Import from zip archive without preserved folder structure
1238 * (Rename All)
1239 * <p>
1240 *
1241 * <pre>
1242 * Procedure : 0) Delete all traces in project
1243 * 1) Open Import wizard
1244 * 2) Select archive file: traces.zip
1245 * 3) Select archive root directory
1246 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and unselect "Preserve Folder Structure"
1247 * 5) press Finish
1248 * 6) When dialog appears select "Rename All"
1249 * </pre>
1250 * <p>
1251 * Expected Results: All traces are imported with trace type set. The traces
1252 * from folder "clashes" are renamed with suffix (2). Make sure that the
1253 * traces can be opened.
1254 */
1255 @Test
1256 public void test3_37ImportZipArchiveNoPreserve() {
1257 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
1258
1259 int optionFlags = 0;
1260 importTrace("traces.zip", null, optionFlags, ImportConfirmation.RENAME_ALL, "");
1261
1262 for (TestTraceInfo info : ALL_TRACEINFOS) {
1263 String traceName = info.getTraceName();
1264 if (CLASHING_TRACEINFOS.contains(info)) {
1265 traceName = toRenamedName(traceName);
1266 }
1267 verifyTrace(info, optionFlags, traceName);
1268 }
1269
1270 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
1271 assertEquals(12, tracesFolderItem.getItems().length);
1272 }
1273
1274 /**
1275 * <p>
1276 * Action : Import from zip archive specific traces
1277 * <p>
1278 *
1279 * <pre>
1280 * Procedure : 0) Delete all traces in project
1281 * 1) Open Import wizard
1282 * 2) Select archive file: traces.zip
1283 * 3) Select file z-clashes/ExampleCustomTxt.log and directory kernel-overlap-testing/
1284 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
1285 * 5) press Finish
1286 * </pre>
1287 * <p>
1288 * Expected Results: The specified traces are imported with trace type set.
1289 * Make sure that the traces can be opened.
1290 */
1291 @Test
1292 public void test3_38ImportZipArchiveSpecificTraces() {
1293 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
1294
1295 int optionFlags = ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE;
1296 importTrace("traces.zip", null, optionFlags, ImportConfirmation.CONTINUE, "z-clashes/ExampleCustomTxt.log", "kernel-overlap-testing/");
1297
1298 verifyTrace(CLASHES_CUSTOM_TEXT_LOG, optionFlags, CLASHES_CUSTOM_TEXT_LOG.getTracePath());
1299 verifyTrace(LTTNG_KERNEL_TRACE, optionFlags, LTTNG_KERNEL_TRACE.getTracePath());
1300
1301 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
1302 assertEquals(2, tracesFolderItem.getItems().length);
1303 SWTBotTreeItem clashesFolderItem = SWTBotUtils.getTraceProjectItem(fBot, tracesFolderItem, CLASHES_DIR_NAME);
1304 assertEquals(1, clashesFolderItem.getItems().length);
1305 }
1306
1307 /**
1308 * <p>
1309 * Action : Import from tar.gz archive with preserved folder structure
1310 * <p>
1311 *
1312 * <pre>
1313 * Procedure : 0) Delete all traces in project
1314 * 1) Open Import wizard
1315 * 2) Select archive file: traces.tar.gz
1316 * 3) Select archive root directory
1317 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
1318 * 5) press Finish
1319 * </pre>
1320 * <p>
1321 * Expected Results: All traces are imported with trace type set. The folder
1322 * "clashes" is imported with traces inside. Make sure that the traces can
1323 * be opened.
1324 */
1325 @Test
1326 public void test3_39ImportTarGzipArchivePreserve() {
1327 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
1328
1329 int optionFlags = ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE;
1330 importTrace("traces.tar.gz", null, optionFlags, ImportConfirmation.CONTINUE, "");
1331
1332 for (TestTraceInfo info : ALL_TRACEINFOS) {
1333 verifyTrace(info, optionFlags, info.getTracePath());
1334 }
1335
1336 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
1337 assertEquals(7, tracesFolderItem.getItems().length);
1338 SWTBotTreeItem clashesFolderItem = SWTBotUtils.getTraceProjectItem(fBot, tracesFolderItem, CLASHES_DIR_NAME);
1339 assertEquals(6, clashesFolderItem.getItems().length);
1340 }
1341
1342 /**
1343 * <p>
1344 * Action : Import from tar.gz archive without preserved folder structure (Rename All)
1345 * <p>
1346 *
1347 * <pre>
1348 * Procedure : 0) Delete all traces in project
1349 * 1) Open Import wizard
1350 * 2) Select archive file: traces.tar.gz
1351 * 3) Select archive root directory
1352 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and unselect "Preserve Folder Structure"
1353 * 5) press Finish
1354 * 6) When dialog appears select "Rename All"
1355 * </pre>
1356 * <p>
1357 * Expected Results: All traces are imported with trace type set. The traces
1358 * from folder "clashes" are renamed with suffix (2). Make sure that the
1359 * traces can be opened.
1360 */
1361 @Test
1362 public void test3_40ImportTarGzipArchiveNoPreserve() {
1363 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
1364
1365 int optionFlags = 0;
1366 importTrace("traces.tar.gz", null, optionFlags, ImportConfirmation.RENAME_ALL, "");
1367
1368 for (TestTraceInfo info : ALL_TRACEINFOS) {
1369 String traceName = info.getTraceName();
1370 if (CLASHING_TRACEINFOS.contains(info)) {
1371 traceName = toRenamedName(traceName);
1372 }
1373 verifyTrace(info, optionFlags, traceName);
1374 }
1375
1376 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
1377 assertEquals(12, tracesFolderItem.getItems().length);
1378 }
1379
1380 /**
1381 * <p>
1382 * Action : Import from tar.gz archive specific traces
1383 * <p>
1384 *
1385 * <pre>
1386 * Procedure : 0) Delete all traces in project
1387 * 1) Open Import wizard
1388 * 2) Select archive file: traces.tar.gz
1389 * 3) Select file z-clashes/ExampleCustomTxt.log and directory kernel-overlap-testing/
1390 * 4) Select trace type "Automatic", unselect "Overwrite existing without warning", and select "Preserve Folder Structure"
1391 * 5) press Finish
1392 * </pre>
1393 * <p>
1394 * Expected Results: The specified traces are imported with trace type set.
1395 * Make sure that the traces can be opened.
1396 */
1397 @Test
1398 public void test3_41ImportTarGzipArchiveSpecificTraces() {
1399 SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
1400
1401 int optionFlags = ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE;
1402 importTrace("traces.tar.gz", null, optionFlags, ImportConfirmation.CONTINUE, "z-clashes/ExampleCustomTxt.log", "kernel-overlap-testing/");
1403
1404 verifyTrace(CLASHES_CUSTOM_TEXT_LOG, optionFlags, CLASHES_CUSTOM_TEXT_LOG.getTracePath());
1405 verifyTrace(LTTNG_KERNEL_TRACE, optionFlags, LTTNG_KERNEL_TRACE.getTracePath());
1406
1407 SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
1408 assertEquals(2, tracesFolderItem.getItems().length);
1409 SWTBotTreeItem clashesFolderItem = SWTBotUtils.getTraceProjectItem(fBot, tracesFolderItem, CLASHES_DIR_NAME);
1410 assertEquals(1, clashesFolderItem.getItems().length);
1411 }
1412
d2fbf6b6
PT
1413 private static void verifyTrace(TestTraceInfo traceInfo, int importOptionFlags) {
1414 verifyTrace(traceInfo, importOptionFlags, traceInfo.getTraceName());
1415 }
1416
ab18f69a
MAL
1417 private static void verifyTrace(TestTraceInfo traceInfo, int importOptionFlags, String traceName) {
1418 verifyTrace(traceInfo, importOptionFlags, traceName, traceInfo.getTraceType());
1419 }
1420
1421 private static void verifyTrace(TestTraceInfo traceInfo, int importOptionFlags, String traceName, String traceType) {
d2fbf6b6
PT
1422 verifyTrace(traceInfo, importOptionFlags, traceName, traceType, TRACE_PROJECT_NAME);
1423 }
1424
1425 private static void verifyTrace(TestTraceInfo traceInfo, int importOptionFlags, String traceName, String traceType, String projectName) {
cdfe10e7 1426 String[] tracePath = new Path(traceName).segments();
d2fbf6b6 1427 SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, projectName), tracePath);
ab18f69a
MAL
1428 checkTraceType(traceItem, traceType);
1429 openTrace(traceItem);
1430 if (traceType != null && !traceType.isEmpty()) {
1431 SWTBotImportWizardUtils.testEventsTable(fBot, traceName, traceInfo.getNbEvents(), traceInfo.getFirstEventTimestamp());
1432 } else {
1433 // If there is no trace type, make sure it can be opened with the text editor
1434 fBot.waitUntil(ConditionHelpers.isEditorOpened(fBot, traceName));
1435 SWTBotEditor editor = fBot.editorByTitle(traceName);
1436 assertEquals(TEXT_EDITOR_ID, editor.getReference().getId());
1437 }
1438 checkTraceLinked(traceItem, (importOptionFlags & ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE) != 0);
1439 }
1440
1441 private static String toRenamedName(String traceName) {
1442 return traceName + "(2)";
1443 }
1444
1445 private static void openTrace(SWTBotTreeItem traceItem) {
1446 traceItem.select();
1447 traceItem.doubleClick();
1448 }
1449
1450 private static void testSingleTrace(TestTraceInfo traceInfo, int optionFlags) {
1451 importTrace(optionFlags, traceInfo.getTracePath());
1452 verifyTrace(traceInfo, optionFlags);
1453 }
1454
1455 private static void importTrace(int optionFlags, String ... tracePaths) {
1456 importTrace(optionFlags, ImportConfirmation.CONTINUE, tracePaths);
1457 }
1458
1459 private static void importTrace(int optionFlags, ImportConfirmation confirmationMode, String ... tracePaths) {
1460 importTrace(null, optionFlags, confirmationMode, tracePaths);
1461 }
1462
1463 private static void importTrace(String traceType, int optionFlags, ImportConfirmation confirmationMode, String ... tracePaths) {
cdfe10e7
PT
1464 importTrace(null, traceType, optionFlags, confirmationMode, tracePaths);
1465 }
1466
1467 private static void importTrace(String archiveFile, String traceType, int optionFlags, ImportConfirmation confirmationMode, String ... tracePaths) {
d2fbf6b6 1468 importTrace(archiveFile, traceType, optionFlags, new ImportConfirmationSupplier(confirmationMode), tracePaths);
ab18f69a
MAL
1469 }
1470
1471 private static void importTrace(int optionFlags, Supplier<ImportConfirmation> confirmationSuplier, String ... tracePaths) {
cdfe10e7 1472 importTrace(null, null, optionFlags, confirmationSuplier, tracePaths);
ab18f69a
MAL
1473 }
1474
cdfe10e7 1475 private static void importTrace(String archiveFile, String traceType, int optionFlags, Supplier<ImportConfirmation> confirmationSuplier, String ... tracePaths) {
ab18f69a 1476 SWTBotTreeItem traceFolder = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
ab18f69a 1477 SWTBotShell shell = openTraceFoldersImport(traceFolder);
d2fbf6b6
PT
1478 importTrace(shell, archiveFile, traceType, optionFlags, confirmationSuplier, tracePaths);
1479 }
1480
1481 /**
1482 * @param tracePaths relative to parent test traces folder
1483 */
1484 private static void importTrace(SWTBotShell shell, String archiveFile, String traceType, int optionFlags, Supplier<ImportConfirmation> confirmationSuplier, String ... tracePaths) {
ab18f69a 1485 SWTBot bot = shell.bot();
cdfe10e7
PT
1486 String rootFolderName;
1487 if (archiveFile == null) {
1488 rootFolderName = "import";
1489 String importDirectoryFullPath = getPath(rootFolderName);
1490 SWTBotImportWizardUtils.selectImportFromDirectory(bot, importDirectoryFullPath);
1491 } else {
1492 rootFolderName = "/";
1493 String importArchiveFullPath = getPath("archives" + File.separator + archiveFile);
1494 SWTBotImportWizardUtils.selectImportFromArchive(bot, importArchiveFullPath);
1495 }
ab18f69a
MAL
1496
1497 for (String tracePath : tracePaths) {
cdfe10e7
PT
1498 IPath somePath = new Path(rootFolderName).append(tracePath);
1499 String[] treePath = somePath.segments();
1500 if (archiveFile != null) {
1501 String[] newPath = new String[treePath.length + 1];
1502 newPath[0] = "/";
1503 System.arraycopy(treePath, 0, newPath, 1, treePath.length);
1504 treePath = newPath;
ab18f69a 1505 }
cdfe10e7 1506 SWTBotImportWizardUtils.selectItem(fBot, treePath);
ab18f69a
MAL
1507 }
1508
1509 SWTBotImportWizardUtils.setOptions(bot, optionFlags, traceType);
1510 bot.button("Finish").click();
1511
1512 ImportConfirmation importConfirmation = confirmationSuplier.get();
1513 while (importConfirmation != null) {
1514 if (importConfirmation != ImportConfirmation.CONTINUE) {
1515 fBot.waitUntil(Conditions.shellIsActive("Confirmation"));
1516 SWTBotShell shell2 = fBot.activeShell();
1517 SWTBotButton button = shell2.bot().button(importConfirmation.getInName());
1518 button.click();
1519 }
1520 importConfirmation = confirmationSuplier.get();
1521 }
1522
1523 fBot.waitUntil(Conditions.shellCloses(shell));
1524 }
1525
1526 private static void checkTraceType(SWTBotTreeItem traceItem, String traceType) {
1527 assertEquals(traceType, getTraceProperty(traceItem, "type"));
1528 }
1529
1530 private static void checkTraceLinked(SWTBotTreeItem traceItem, boolean linked) {
1531 assertEquals(Boolean.toString(linked), getTraceProperty(traceItem, "linked"));
1532 }
1533
1534 private static String getTraceProperty(SWTBotTreeItem traceItem, String property) {
1535 SWTBotUtils.openView(IPageLayout.ID_PROP_SHEET);
1536 SWTBotView view = fBot.viewById(IPageLayout.ID_PROP_SHEET);
1537 view.show();
1538 traceItem.select();
1539 SWTBotTreeItem traceTypeItem = SWTBotUtils.getTreeItem(view.bot(), view.bot().tree(), "Resource properties", property);
1540 return traceTypeItem.cell(1);
1541 }
1542
1543 private static SWTBotShell openTraceFoldersImport(SWTBotTreeItem traceItem) {
1544 traceItem.contextMenu().menu("Import...").click();
1545 fBot.waitUntil(Conditions.shellIsActive("Trace Import"));
1546
1547 SWTBotShell shell = fBot.shell("Trace Import");
1548 return shell;
1549 }
d2fbf6b6
PT
1550
1551 private static SWTBotShell openWorkbenchMenuImport() {
1552 fBot.menu().menu("File", "Import...").click();
1553 fBot.waitUntil(Conditions.shellIsActive("Import"));
1554
1555 SWTBot shellBot = fBot.shell("Import").bot();
1556 SWTBotTree tree = shellBot.tree();
1557 SWTBotUtils.getTreeItem(fBot, tree, "Tracing", "Trace Import").select();
1558 shellBot.button("Next >").click();
1559 SWTBotShell shell = fBot.shell("Trace Import");
1560 return shell;
1561 }
ab18f69a 1562}
This page took 0.102942 seconds and 5 git commands to generate.