Commit | Line | Data |
---|---|---|
4b451cbe | 1 | /******************************************************************************* |
ed902a2b | 2 | * Copyright (c) 2013, 2015 Ericsson |
4b451cbe MK |
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 | * Contributors: | |
10 | * Matthew Khouzam - Initial API and implementation | |
11 | * Marc-Andre Laperle | |
2f7b3dd7 | 12 | * Bernd Hufmann - Extracted functionality to class AbstractImportAndReadSmokeTest |
4b451cbe MK |
13 | *******************************************************************************/ |
14 | ||
2bdf0193 | 15 | package org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests; |
4b451cbe MK |
16 | |
17 | import static org.junit.Assert.assertNotNull; | |
4b451cbe | 18 | |
9b3f4afe | 19 | import org.eclipse.core.runtime.Path; |
4b451cbe MK |
20 | import org.eclipse.jface.viewers.StructuredSelection; |
21 | import org.eclipse.jface.wizard.IWizardPage; | |
4b451cbe | 22 | import org.eclipse.jface.wizard.WizardDialog; |
4b451cbe | 23 | import org.eclipse.swt.widgets.Shell; |
4b451cbe | 24 | import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; |
cbbd323f | 25 | import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; |
4b451cbe | 26 | import org.eclipse.swtbot.swt.finder.results.VoidResult; |
4b451cbe MK |
27 | import org.eclipse.swtbot.swt.finder.waits.Conditions; |
28 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton; | |
4b451cbe MK |
29 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; |
30 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; | |
2bdf0193 AM |
31 | import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.BatchImportTraceWizard; |
32 | import org.eclipse.tracecompass.tmf.ui.editors.TmfEventsEditor; | |
fa24d78b AM |
33 | import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers; |
34 | import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils; | |
4b451cbe MK |
35 | import org.eclipse.ui.IWorkbench; |
36 | import org.eclipse.ui.IWorkbenchWindow; | |
37 | import org.eclipse.ui.PlatformUI; | |
4b451cbe | 38 | import org.junit.Test; |
cbbd323f | 39 | import org.junit.runner.RunWith; |
4b451cbe MK |
40 | |
41 | /** | |
42 | * SWTBot Smoke test. base for other tests | |
43 | * | |
44 | * @author Matthew Khouzam | |
45 | */ | |
cbbd323f | 46 | @RunWith(SWTBotJunit4ClassRunner.class) |
2f7b3dd7 | 47 | public class ImportAndReadSmokeTest extends AbstractImportAndReadSmokeTest { |
306e18d0 | 48 | |
4b451cbe | 49 | private static final String TRACE_PROJECT_NAME = "test"; |
4b451cbe MK |
50 | |
51 | /** | |
52 | * Main test case | |
53 | */ | |
54 | @Test | |
55 | public void test() { | |
56 | createProject(); | |
57 | ||
58 | batchImportOpenWizard(); | |
59 | batchImportSelecTraceType(); | |
60 | batchImportAddDirectory(); | |
61 | batchImportSelectTrace(); | |
2f7b3dd7 | 62 | importFinish(); |
4b451cbe | 63 | |
fa24d78b | 64 | TmfEventsEditor tmfEd = SWTBotUtils.openEditor(fBot, getProjectName(), new Path(TRACE_NAME)); |
4b451cbe MK |
65 | |
66 | testHistogramView(getViewPart("Histogram"), tmfEd); | |
67 | testPropertyView(getViewPart("Properties")); | |
68 | testStatisticsView(getViewPart("Statistics")); | |
93c91230 | 69 | fBot.closeAllEditors(); |
4b451cbe | 70 | |
fa24d78b | 71 | SWTBotUtils.deleteProject(getProjectName(), fBot); |
4b451cbe MK |
72 | } |
73 | ||
4b451cbe MK |
74 | private static void batchImportOpenWizard() { |
75 | fWizard = new BatchImportTraceWizard(); | |
76 | ||
77 | UIThreadRunnable.asyncExec(new VoidResult() { | |
78 | @Override | |
79 | public void run() { | |
80 | final IWorkbench workbench = PlatformUI.getWorkbench(); | |
81 | // Fire the Import Trace Wizard | |
82 | if (workbench != null) { | |
83 | final IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); | |
84 | Shell shell = activeWorkbenchWindow.getShell(); | |
85 | assertNotNull(shell); | |
86 | ((BatchImportTraceWizard) fWizard).init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY); | |
87 | WizardDialog dialog = new WizardDialog(shell, fWizard); | |
88 | dialog.open(); | |
89 | } | |
90 | } | |
91 | }); | |
92 | ||
93 | fBot.waitUntil(ConditionHelpers.isWizardReady(fWizard)); | |
94 | } | |
95 | ||
96 | private static void batchImportSelecTraceType() { | |
97 | final SWTBotTree tree = fBot.tree(); | |
98 | final String ctfId = "Common Trace Format"; | |
99 | fBot.waitUntil(ConditionHelpers.IsTreeNodeAvailable(ctfId, tree)); | |
100 | fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(TRACE_TYPE_NAME, tree.getTreeItem(ctfId))); | |
101 | tree.getTreeItem(ctfId).getNode(TRACE_TYPE_NAME).check(); | |
102 | batchImportClickNext(); | |
103 | } | |
104 | ||
105 | private static void batchImportAddDirectory() { | |
106 | UIThreadRunnable.syncExec(new VoidResult() { | |
107 | @Override | |
108 | public void run() { | |
109 | ((BatchImportTraceWizard) fWizard).addFileToScan(fTrace.getPath()); | |
110 | } | |
111 | }); | |
112 | final SWTBotButton removeButton = fBot.button("Remove"); | |
113 | fBot.waitUntil(Conditions.widgetIsEnabled(removeButton)); | |
114 | removeButton.click(); | |
115 | fBot.waitUntil(Conditions.tableHasRows(fBot.table(), 1)); | |
116 | ||
117 | batchImportClickNext(); | |
118 | } | |
119 | ||
120 | private static void batchImportSelectTrace() { | |
121 | SWTBotTree tree = fBot.tree(); | |
122 | fBot.waitUntil(Conditions.widgetIsEnabled(tree)); | |
123 | final SWTBotTreeItem genericCtfTreeItem = tree.getTreeItem(TRACE_TYPE_NAME); | |
124 | fBot.waitUntil(Conditions.widgetIsEnabled(genericCtfTreeItem)); | |
125 | genericCtfTreeItem.expand(); | |
126 | genericCtfTreeItem.check(); | |
127 | batchImportClickNext(); | |
128 | } | |
129 | ||
130 | private static void batchImportClickNext() { | |
131 | IWizardPage currentPage = fWizard.getContainer().getCurrentPage(); | |
132 | IWizardPage desiredPage = fWizard.getNextPage(currentPage); | |
133 | SWTBotButton nextButton = fBot.button("Next >"); | |
134 | nextButton.click(); | |
135 | fBot.waitUntil(ConditionHelpers.isWizardOnPage(fWizard, desiredPage)); | |
136 | } | |
137 | ||
2f7b3dd7 BH |
138 | @Override |
139 | protected String getProjectName() { | |
140 | return TRACE_PROJECT_NAME; | |
4b451cbe | 141 | } |
4b451cbe | 142 | } |