tmf.xml: Add SWTBot XML timegraph view test
authorJean-Christian Kouame <jean-christian.kouame@ericsson.com>
Fri, 16 Dec 2016 21:04:59 +0000 (16:04 -0500)
committerJean-Christian Kouame <jean-christian.kouame@ericsson.com>
Mon, 19 Dec 2016 20:01:20 +0000 (15:01 -0500)
This test the loading and and viewing of xml trace. An
Xml view is created then validated.

Change-Id: I908771685129942eb044a2dbb497e377180a202e
Signed-off-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/87340
Reviewed-by: Hudson CI
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/build.properties
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/common/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/common/TmfXmlTestFiles.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_valid/test_valid_xml_timegraphView.xml [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests/build.properties
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/swtbot/tests/timegraph/XmlTimegraphViewTest.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/META-INF/MANIFEST.MF

index 84e7c9cde0aee807c935d1a0869eb258daf32f39..8ea73e9d8b514c33e55adcc1f5eb014d09dbf6df 100644 (file)
@@ -17,7 +17,8 @@ bin.includes = META-INF/,\
                .,\
                about.html,\
                plugin.xml,\
-               test_xml_files/
+               test_xml_files/,\
+               test_traces/
 src.includes = about.html
 additional.bundles = org.eclipse.jdt.annotation
 jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation
index c0dafe2f554a15efd2507313d9628f458a23c20f..9d6afb9d9370e947c853808b099b025067f2c3d0 100644 (file)
@@ -53,7 +53,9 @@ public enum TmfXmlTestFiles {
     /** A valid pattern file to test the initialState element */
     INITIAL_STATE_ELEMENT_TEST_FILE_1("test_xml_files/test_valid/test_initialState_element1.xml"),
     /** A valid pattern file to test the initialState element */
-    INITIAL_STATE_ELEMENT_TEST_FILE_2("test_xml_files/test_valid/test_initialState_element2.xml");
+    INITIAL_STATE_ELEMENT_TEST_FILE_2("test_xml_files/test_valid/test_initialState_element2.xml"),
+    /** A valid xml timegraph view */
+    VALID_TIMEGRAPH_VIEW_ELEMENT_FILE("test_xml_files/test_valid/test_valid_xml_timegraphView.xml");
 
     private final String fPath;
 
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_valid/test_valid_xml_timegraphView.xml b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_valid/test_valid_xml_timegraphView.xml
new file mode 100644 (file)
index 0000000..6bb869d
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ***************************************************************************
+* Copyright (c) 2016 Ericsson
+*
+* All rights reserved. This program and the accompanying materials are
+* made available under the terms of the Eclipse Public License v1.0 which
+* accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+*   Jean-Christian Kouame - Initial API and implementation
+*************************************************************************** -->
+<tmfxml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:noNamespaceSchemaLocation="xmlDefinition.xsd">
+       <timeGraphView id="org.eclipse.linuxtools.tmf.analysis.xml.ui.views.controlflow">
+               <head>
+                       <analysis id="test.xml.conditions" />
+                       <label value="Xml Timegraph View Test" />
+               </head>
+               <!-- StateValues -->
+               <definedValue name="NONE" value="0" color="#EEEEEE" />
+               <definedValue name="VALID" value="1" color="#FF0000" />
+       
+               <entry path="checkpoint">
+                       <display type="self"/>
+               </entry>
+       </timeGraphView>
+</tmfxml>
\ No newline at end of file
index e50d3b50c8c02c317fbd7577dc1d6e0edc93af4e..eb24419b20949f975a489ca0641c62c7ca4089b1 100644 (file)
@@ -17,4 +17,6 @@ bin.includes = META-INF/,\
                about.html
 src.includes = about.html
 additional.bundles = org.eclipse.jdt.annotation
-jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation
+jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation,\
+                       target/org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests-1.0.1-SNAPSHOT.jar,\
+                       target/org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests-1.0.1-SNAPSHOT-sources.jar
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/swtbot/tests/timegraph/XmlTimegraphViewTest.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/swtbot/tests/timegraph/XmlTimegraphViewTest.java
new file mode 100644 (file)
index 0000000..2095734
--- /dev/null
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests.timegraph;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlAnalysisModuleSource;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlUtils;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.timegraph.XmlTimeGraphView;
+import org.eclipse.tracecompass.tmf.analysis.xml.core.tests.Activator;
+import org.eclipse.tracecompass.tmf.analysis.xml.core.tests.common.TmfXmlTestFiles;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraphEntry;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
+import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils;
+import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Class for XML Timegraph View test
+ *
+ * @author Jean-Christian Kouame
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class XmlTimegraphViewTest {
+
+    private static final String PROJECT_NAME = "test";
+    private static final String TRACE_TYPE = "org.eclipse.linuxtools.tmf.core.tests.xmlstub";
+    private static final String TRACE_NAME = "testTrace2.xml";
+    private static final String ANALYSIS_NAME = "test.xml.conditions";
+    private static final String VIEW_NAME = "Xml Timegraph View Test";
+    private static SWTWorkbenchBot fBot;
+
+    /**
+     * Things to setup
+     */
+    @Before
+    public void before() {
+
+        SWTBotUtils.initialize();
+        Thread.currentThread().setName("SWTBotTest");
+        /* set up for swtbot */
+        SWTBotPreferences.TIMEOUT = 10000; /* 10 second timeout */
+        SWTWorkbenchBot bot = new SWTWorkbenchBot();
+        SWTBotUtils.closeView("welcome", bot);
+        /* Switch perspectives */
+        SWTBotUtils.switchToTracingPerspective();
+        /* Finish waiting for eclipse to load */
+        WaitUtils.waitForJobs();
+
+        fBot = new SWTWorkbenchBot();
+
+        loadXmlFile();
+        openTrace();
+        openView(VIEW_NAME);
+    }
+
+    /**
+     * Bypassing the native import wizard and programmatically load the XML
+     * analysis
+     */
+    private static void loadXmlFile() {
+        XmlUtils.addXmlFile(TmfXmlTestFiles.CONDITION_FILE.getFile());
+        XmlUtils.addXmlFile(TmfXmlTestFiles.VALID_TIMEGRAPH_VIEW_ELEMENT_FILE.getFile());
+        XmlAnalysisModuleSource.notifyModuleChange();
+    }
+
+    /**
+     * Create a tracing project and open the test trace
+     */
+    private static void openTrace() {
+        SWTBotUtils.createProject(PROJECT_NAME);
+        SWTBotUtils.openTrace(PROJECT_NAME, Activator.getAbsolutePath(new Path("test_traces/testTrace2.xml")).toString(), TRACE_TYPE);
+        WaitUtils.waitForJobs();
+    }
+
+    /**
+     * Open a the timegraph view
+     *
+     * @param viewTitle
+     *            The view title
+     */
+    private static void openView(final String viewTitle) {
+        SWTBotTreeItem treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);
+        treeItem = SWTBotUtils.getTreeItem(fBot, treeItem, TRACE_NAME, "Views", ANALYSIS_NAME, viewTitle);
+        treeItem.doubleClick();
+    }
+
+    /**
+     * Test that the timegraph view is open and is populated
+     */
+    @Test
+    public void testData() {
+        SWTBotTimeGraph timegraph = getTimegraph();
+
+        // Test the window range
+        TimeGraphControl widget = timegraph.widget;
+        assertNotNull(widget);
+        assertEquals("window start time", 1, widget.getTimeDataProvider().getTime0());
+        assertEquals("window end time", 7, widget.getTimeDataProvider().getTime1());
+
+        // test entries
+        SWTBotTimeGraphEntry[] entries = timegraph.getEntries();
+        assertEquals("number of entries", 1, entries.length);
+        entries = entries[0].getEntries();
+        assertEquals("number of entries", 1, entries.length);
+        SWTBotTimeGraphEntry entry = entries[0];
+        assertNotNull(entry);
+        assertEquals("name of entries[0]", "checkpoint", entry.getText());
+    }
+
+    private static SWTBotTimeGraph getTimegraph() {
+        SWTBotView viewBot = fBot.viewById(XmlTimeGraphView.ID);
+        SWTBotTimeGraph timegraph = new SWTBotTimeGraph(viewBot.bot());
+        assertTrue("timegraph visible", timegraph.isVisible());
+        timegraph.setFocus();
+        return timegraph;
+    }
+
+    /**
+     * Close the editor and delete the project
+     */
+    @After
+    public void tearDown() {
+        fBot.closeAllEditors();
+        SWTBotUtils.deleteProject(PROJECT_NAME, fBot);
+    }
+}
index abade422f82385c7d69e5d954c79e6c3fae4301d..535d0f4519645a211518c95bf8072c75106330b3 100644 (file)
@@ -27,7 +27,7 @@ Export-Package: org.eclipse.tracecompass.internal.tmf.analysis.xml.ui;x-friends:
  org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.module;x-friends:="org.eclipse.tracecompass.tmf.analysis.xml.ui.tests",
  org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views;x-internal:=true,
  org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency;x-friends:="org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests",
- org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.timegraph;x-internal:=true,
+ org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.timegraph;x-friends:="org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests",
  org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.xychart;x-internal:=true
 Import-Package: com.google.common.collect,
  org.eclipse.ui.views.properties
This page took 0.028278 seconds and 5 git commands to generate.