releng: ProjectExplorer tests stability improvement
[deliverable/tracecompass.git] / releng / org.eclipse.tracecompass.integration.swtbot.tests / src / org / eclipse / tracecompass / integration / swtbot / tests / projectexplorer / ProjectExplorerTraceActionsTest.java
index 675d0a5795c6c10802665031004dfde4786fe0fd..672dff9afdb38022c2bd655de099288f09b28f27 100644 (file)
@@ -23,7 +23,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
 import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
 import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
@@ -32,11 +31,11 @@ import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
 import org.eclipse.swtbot.swt.finder.waits.Conditions;
 import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
+import org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests.SWTBotImportWizardUtils;
 import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
 import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
 import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils;
@@ -167,7 +166,7 @@ public class ProjectExplorerTraceActionsTest {
         SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), TRACE_NAME);
 
         traceItem.contextMenu().menu("Open").click();
-        testEventsTable(TRACE_NAME);
+        SWTBotImportWizardUtils.testEventsTable(fBot, TRACE_NAME, CUSTOM_TEXT_LOG.getNbEvents(), CUSTOM_TEXT_LOG.getFirstEventTimestamp());
         testStatisticsView();
         fBot.closeAllEditors();
     }
@@ -192,7 +191,7 @@ public class ProjectExplorerTraceActionsTest {
         fBot.closeAllEditors();
         SWTBotTreeItem copiedItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), RENAMED_TRACE_NAME);
         copiedItem.contextMenu().menu("Open").click();
-        testEventsTable(RENAMED_TRACE_NAME);
+        SWTBotImportWizardUtils.testEventsTable(fBot, RENAMED_TRACE_NAME, CUSTOM_TEXT_LOG.getNbEvents(), CUSTOM_TEXT_LOG.getFirstEventTimestamp());
         fBot.closeAllEditors();
         SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
     }
@@ -223,7 +222,7 @@ public class ProjectExplorerTraceActionsTest {
 
         SWTBotTreeItem copiedItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), RENAMED_TRACE_NAME);
         copiedItem.contextMenu().menu("Open").click();
-        testEventsTable(RENAMED_TRACE_NAME);
+        SWTBotImportWizardUtils.testEventsTable(fBot, RENAMED_TRACE_NAME, CUSTOM_TEXT_LOG.getNbEvents(), CUSTOM_TEXT_LOG.getFirstEventTimestamp());
         fBot.closeAllEditors();
         SWTBotUtils.clearTracesFolderUI(fBot, TRACE_PROJECT_NAME);
     }
@@ -273,7 +272,7 @@ public class ProjectExplorerTraceActionsTest {
         traceItem.select();
         fBot.activeShell().pressShortcut(Keystrokes.CR);
 
-        testEventsTable(TRACE_NAME);
+        SWTBotImportWizardUtils.testEventsTable(fBot, TRACE_NAME, CUSTOM_TEXT_LOG.getNbEvents(), CUSTOM_TEXT_LOG.getFirstEventTimestamp());
         testStatisticsView();
         fBot.closeAllEditors();
     }
@@ -320,7 +319,7 @@ public class ProjectExplorerTraceActionsTest {
         SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), TRACE_NAME);
         traceItem.doubleClick();
 
-        testEventsTable(TRACE_NAME);
+        SWTBotImportWizardUtils.testEventsTable(fBot, TRACE_NAME, CUSTOM_TEXT_LOG.getNbEvents(), CUSTOM_TEXT_LOG.getFirstEventTimestamp());
         testStatisticsView();
         fBot.closeAllEditors();
     }
@@ -367,38 +366,6 @@ public class ProjectExplorerTraceActionsTest {
         fBot.waitUntil(Conditions.shellCloses(shell));
     }
 
-    private static void testEventsTable(String editorName) {
-        SWTBotEditor editor = SWTBotUtils.activeEventsEditor(fBot, editorName);
-        fBot.waitUntil(ConditionHelpers.numberOfEventsInTrace(TmfTraceManager.getInstance().getActiveTrace(), CUSTOM_TEXT_LOG.getNbEvents()));
-
-        SWTBotTable table = editor.bot().table();
-        fBot.waitUntil(new DefaultCondition() {
-            @Override
-            public boolean test() throws Exception {
-                return table.rowCount() > 1;
-            }
-
-            @Override
-            public String getFailureMessage() {
-                return "No items in table";
-            }
-        });
-        // Select first event (skip filter/search row)
-        table.getTableItem(1).select();
-
-        editor.bot().waitUntil(new DefaultCondition() {
-            @Override
-            public boolean test() throws Exception {
-                return table.selection().rowCount() == 1 && table.selection().get(0).toString().contains(CUSTOM_TEXT_LOG.getFirstEventTimestamp());
-            }
-
-            @Override
-            public String getFailureMessage() {
-                return "First event not selected";
-            }
-        });
-    }
-
     private static void testStatisticsView() {
         SWTBotUtils.openView(TmfStatisticsView.ID);
         SWTBotView view = fBot.viewById(TmfStatisticsView.ID);
This page took 0.02536 seconds and 5 git commands to generate.