From 9bfd623ff14699254b04912e31308eba9c503af6 Mon Sep 17 00:00:00 2001 From: Marc-Andre Laperle Date: Thu, 25 Aug 2016 23:15:41 -0400 Subject: [PATCH] tmf: Use SWTBotUtils.selectTracesFolder to simplify in a few places Change-Id: I67f06aba3256ea405c9c6eea9675ab1657a2aba4 Signed-off-by: Marc-Andre Laperle Reviewed-on: https://git.eclipse.org/r/79791 Reviewed-by: Hudson CI Reviewed-by: Patrick Tasse Tested-by: Patrick Tasse --- .../parsers/custom/TestCustomTxtWizard.java | 30 ++----------------- .../parsers/custom/TestCustomXmlWizard.java | 17 +---------- 2 files changed, 3 insertions(+), 44 deletions(-) diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/TestCustomTxtWizard.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/TestCustomTxtWizard.java index 29741d6d0b..e933e852e6 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/TestCustomTxtWizard.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/TestCustomTxtWizard.java @@ -21,7 +21,6 @@ import java.io.FileWriter; import java.io.IOException; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.swtbot.swt.finder.waits.Conditions; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; @@ -99,20 +98,8 @@ public class TestCustomTxtWizard extends AbstractCustomParserWizard { File xmlFile = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(".metadata/.plugins/org.eclipse.tracecompass.tmf.core/custom_txt_parsers.xml").toFile(); // Open the custom parsers dialog SWTBotUtils.createProject(PROJECT_NAME); - SWTBotView projectExplorerBot = fBot.viewByTitle("Project Explorer"); - projectExplorerBot.show(); - SWTBotTreeItem treeItem = projectExplorerBot.bot().tree().getTreeItem(PROJECT_NAME); - treeItem.select(); - treeItem.expand(); - SWTBotTreeItem treeNode = null; - for (String node : treeItem.getNodes()) { - if (node.startsWith("Trace")) { - treeNode = treeItem.getNode(node); - break; - } - } - assertNotNull(treeNode); + SWTBotTreeItem treeNode = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); treeNode.contextMenu("Manage Custom Parsers...").click(); fBot.waitUntil(Conditions.shellIsActive(MANAGE_CUSTOM_PARSERS_SHELL_TITLE)); fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).setFocus(); @@ -215,20 +202,7 @@ public class TestCustomTxtWizard extends AbstractCustomParserWizard { } // Open the custom parsers dialog SWTBotUtils.createProject(PROJECT_NAME); - SWTBotView proejctExplorerBot = fBot.viewByTitle("Project Explorer"); - proejctExplorerBot.show(); - SWTBotTreeItem treeItem = proejctExplorerBot.bot().tree().getTreeItem(PROJECT_NAME); - treeItem.select(); - treeItem.expand(); - SWTBotTreeItem treeNode = null; - for (String node : treeItem.getNodes()) { - if (node.startsWith("Trace")) { - treeNode = treeItem.getNode(node); - break; - } - - } - assertNotNull(treeNode); + SWTBotTreeItem treeNode = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); treeNode.contextMenu("Manage Custom Parsers...").click(); fBot.waitUntil(Conditions.shellIsActive(MANAGE_CUSTOM_PARSERS_SHELL_TITLE)); // Open the edition dialog for txt parser diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/TestCustomXmlWizard.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/TestCustomXmlWizard.java index a8f443cebf..bf7759b7fc 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/TestCustomXmlWizard.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/TestCustomXmlWizard.java @@ -13,14 +13,12 @@ package org.eclipse.tracecompass.tmf.ui.swtbot.tests.parsers.custom; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.swtbot.swt.finder.waits.Conditions; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; @@ -74,20 +72,7 @@ public class TestCustomXmlWizard extends AbstractCustomParserWizard { public void testNew() throws FileNotFoundException, IOException { File xmlFile = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(".metadata/.plugins/org.eclipse.tracecompass.tmf.core/custom_xml_parsers.xml").toFile(); SWTBotUtils.createProject(PROJECT_NAME); - SWTBotView proejctExplorerBot = fBot.viewByTitle("Project Explorer"); - proejctExplorerBot.show(); - SWTBotTreeItem treeItem = proejctExplorerBot.bot().tree().getTreeItem(PROJECT_NAME); - treeItem.select(); - treeItem.expand(); - SWTBotTreeItem treeNode = null; - for (String node : treeItem.getNodes()) { - if (node.startsWith("Trace")) { - treeNode = treeItem.getNode(node); - break; - } - - } - assertNotNull(treeNode); + SWTBotTreeItem treeNode = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); treeNode.contextMenu("Manage Custom Parsers...").click(); fBot.waitUntil(Conditions.shellIsActive(MANAGE_CUSTOM_PARSERS_SHELL_TITLE)); fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).setFocus(); -- 2.34.1