tmf: Use SWTBotUtils.selectTracesFolder to simplify in a few places
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui.swtbot.tests / src / org / eclipse / tracecompass / tmf / ui / swtbot / tests / parsers / custom / TestCustomXmlWizard.java
index 2a268ae128d00a9e752e4bafec170d588d813bfa..bf7759b7fca2a61e244204ee4ebea805f0361cd1 100644 (file)
 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;
 import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
 import org.junit.Test;
@@ -41,6 +40,7 @@ public class TestCustomXmlWizard extends AbstractCustomParserWizard {
     private static final String TRACE = "trace";
     private static final String XML_TRACE1 = "<trace>\n\t<event time=\"100\" msg=\"hello\"/>\n\t<event time=\"200\" msg=\"world\"/></trace>";
     private static final String MANAGE_CUSTOM_PARSERS_SHELL_TITLE = "Manage Custom Parsers";
+    private static final String CUSTOM_XML_PARSER_SHELL_TITLE = "Custom XML Parser";
     private static final String PROJECT_NAME = "TestXML";
     private static final String CATEGORY_NAME = "Test Category";
     private static final String TRACETYPE_NAME = "Test Trace";
@@ -48,17 +48,17 @@ public class TestCustomXmlWizard extends AbstractCustomParserWizard {
             "<TimeStampOutputFormat>ss</TimeStampOutputFormat>\n" +
             "<InputElement name=\"trace\">\n" +
             "<InputElement logentry=\"true\" name=\"event\">\n" +
-            "<InputData action=\"0\" format=\"\" name=\"Ignore\"/>\n" +
+            "<InputData action=\"0\" name=\"Ignore\" tag=\"IGNORE\"/>\n" +
             "<Attribute name=\"msg\">\n" +
-            "<InputData action=\"0\" name=\"msg\"/>\n" +
+            "<InputData action=\"0\" name=\"msg\" tag=\"OTHER\"/>\n" +
             "</Attribute>\n" +
             "<Attribute name=\"time\">\n" +
-            "<InputData action=\"0\" name=\"time\"/>\n" +
+            "<InputData action=\"0\" name=\"time\" tag=\"OTHER\"/>\n" +
             "</Attribute>\n" +
             "</InputElement>\n" +
             "</InputElement>\n" +
-            "<OutputColumn name=\"msg\"/>\n" +
-            "<OutputColumn name=\"time\"/>\n";
+            "<OutputColumn name=\"msg\" tag=\"OTHER\"/>\n" +
+            "<OutputColumn name=\"time\" tag=\"OTHER\"/>\n";
 
     /**
      * Test to create a custom XML trace and compare the XML generated
@@ -72,24 +72,13 @@ 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();
         fBot.radio("XML").click();
         fBot.button("New...").click();
+        fBot.waitUntil(Conditions.shellIsActive(CUSTOM_XML_PARSER_SHELL_TITLE));
         fBot.textWithLabel("Category:").setText(CATEGORY_NAME);
         fBot.textWithLabel("Trace type:").setText(TRACETYPE_NAME);
         fBot.textWithLabel("Time Stamp format:").setText("ss");
This page took 0.024512 seconds and 5 git commands to generate.