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