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