ust: Add initial SwtBot test for memory usage view
authorBernd Hufmann <Bernd.Hufmann@ericsson.com>
Fri, 27 Nov 2015 20:36:28 +0000 (15:36 -0500)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Tue, 1 Dec 2015 18:32:29 +0000 (13:32 -0500)
Change-Id: Ied9bb9b8539e3a15cc8facc6678f486c2e092558
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/61504
Reviewed-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/META-INF/MANIFEST.MF
lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/AllTests.java
lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/MemoryUsageViewTest.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.ust.ui/META-INF/MANIFEST.MF
releng/org.eclipse.tracecompass.target/tracecompass-e4.5.target
releng/org.eclipse.tracecompass.target/tracecompass-eStaging.target

index 7c9f3a6014bbab344f5dff059496d29be235acf2..e7565b853e7f091931967c05bd06e6917873d357 100644 (file)
@@ -24,7 +24,8 @@ Require-Bundle: org.apache.log4j,
  org.eclipse.ui.views,
  org.junit,
  org.eclipse.tracecompass.lttng2.ust.core,
- org.eclipse.tracecompass.lttng2.ust.ui
+ org.eclipse.tracecompass.lttng2.ust.ui,
+ org.swtchart
 Export-Package: org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests
 Import-Package: com.google.common.collect,
- org.eclipse.tracecompass.testtraces.ctf;version="1.0.0"
+ org.eclipse.tracecompass.testtraces.ctf;version="1.1.1"
index f7f36247df9f1816514577ddc0418dcf1b076640..f1d523a82015c74a881b3170016ead1c4ce64462 100644 (file)
@@ -20,7 +20,8 @@ import org.junit.runners.Suite;
  */
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
-    CallStackViewTest.class
+    CallStackViewTest.class,
+    MemoryUsageViewTest.class
 })
 public class AllTests {
 
diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/MemoryUsageViewTest.java b/lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/MemoryUsageViewTest.java
new file mode 100644 (file)
index 0000000..5a31373
--- /dev/null
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.lttng2.ust.ui.swtbot.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Logger;
+import org.apache.log4j.SimpleLayout;
+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.matchers.WidgetOfType;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.tracecompass.internal.lttng2.ust.ui.views.memusage.MemoryUsageView;
+import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
+import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
+import org.hamcrest.Matcher;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.swtchart.Chart;
+import org.swtchart.ILineSeries;
+import org.swtchart.ISeries;
+import org.swtchart.ISeriesSet;
+
+/**
+ * Test for the Memory Usage view in trace compass
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class MemoryUsageViewTest {
+
+    private static final String UST_ID = "org.eclipse.linuxtools.lttng2.ust.tracetype";
+
+    private static final String PROJECT_NAME = "TestForMemory";
+
+    /** The Log4j logger instance. */
+    private static final Logger fLogger = Logger.getRootLogger();
+    private static SWTWorkbenchBot fBot;
+
+    /**
+     * Initialization
+     */
+    @BeforeClass
+    public static void init() {
+        SWTBotUtils.initialize();
+
+        Thread.currentThread().setName("SWTBot Thread"); // for the debugger
+        /* set up for swtbot */
+        SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
+        fLogger.addAppender(new ConsoleAppender(new SimpleLayout()));
+        fBot = new SWTWorkbenchBot();
+
+        SWTBotUtils.closeView("welcome", fBot);
+
+        SWTBotUtils.switchToTracingPerspective();
+
+        /* finish waiting for eclipse to load */
+        SWTBotUtils.waitForJobs();
+    }
+
+    /**
+     * Open a trace in an editor
+     */
+    @Before
+    public void beforeTest() {
+        SWTBotUtils.createProject(PROJECT_NAME);
+        SWTBotTreeItem treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);
+        assertNotNull(treeItem);
+        final CtfTestTrace cygProfile = CtfTestTrace.MEMORY_ANALYSIS;
+        final File file = new File(CtfTmfTestTraceUtils.getTrace(cygProfile).getPath());
+        SWTBotUtils.openTrace(PROJECT_NAME, file.getAbsolutePath(), UST_ID);
+        SWTBotUtils.openView(MemoryUsageView.ID);
+        SWTBotUtils.waitForJobs();
+    }
+
+    /**
+     * Close the editor
+     */
+    @After
+    public void tearDown() {
+        fBot.closeAllEditors();
+        SWTBotUtils.deleteProject(PROJECT_NAME, fBot);
+    }
+
+    /**
+     * Test if Memory Usage is populated
+     */
+    @Test
+    public void testOpenMemoryUsage() {
+        SWTBotView viewBot = fBot.viewById(MemoryUsageView.ID);
+        viewBot.setFocus();
+
+        // Do some basic validation
+        Matcher<Chart> matcher = WidgetOfType.widgetOfType(Chart.class);
+        Chart chart = viewBot.bot().widget(matcher);
+        ISeriesSet seriesSet = chart.getSeriesSet();
+        assertNotNull(seriesSet);
+        ISeries[] series = seriesSet.getSeries();
+        assertNotNull(series);
+
+        // Verify that the chart has 4 series
+        assertEquals(4, series.length);
+        // Verify that each series is a ILineSeries
+        for (int i = 0; i < series.length; i++) {
+            assertTrue(series[i] instanceof ILineSeries);
+        }
+    }
+
+}
\ No newline at end of file
index 6718452b120e16e56cf3d171f81bba6e58a76577..852dcd5c1380c2b3b7207ae4025b7d4f5c35cca0 100644 (file)
@@ -17,5 +17,5 @@ Require-Bundle: org.eclipse.core.resources,
  org.eclipse.tracecompass.tmf.ui,
  org.eclipse.tracecompass.tmf.ctf.core
 Export-Package: org.eclipse.tracecompass.internal.lttng2.ust.ui;x-friends:="org.eclipse.tracecompass.lttng2.ust.ui.tests",
- org.eclipse.tracecompass.internal.lttng2.ust.ui.views.memusage;x-friends:="org.eclipse.tracecompass.lttng2.ust.ui.tests",
+ org.eclipse.tracecompass.internal.lttng2.ust.ui.views.memusage;x-friends:="org.eclipse.tracecompass.lttng2.ust.ui.tests,org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests",
  org.eclipse.tracecompass.lttng2.ust.ui.analysis.callstack
index c2931904fdb5bfd3e640dfb0a441b826bcb5b9e1..4ac234996baf4ea627d54a63111a48f7b1c52e54 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.8"?><target name="tracecompass-e4.5" sequenceNumber="58">
+<?pde version="3.8"?><target name="tracecompass-e4.5" sequenceNumber="60">
 <locations>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
 <unit id="org.eclipse.cdt.gnu.dsf.feature.group" version="0.0.0"/>
@@ -49,7 +49,7 @@
 <repository location="http://download.eclipse.org/eclipse/updates/4.5/"/>
 </location>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
-<unit id="org.eclipse.tracecompass.testtraces.tracecompass-test-traces-ctf" version="1.0.0"/>
+<unit id="org.eclipse.tracecompass.testtraces.tracecompass-test-traces-ctf" version="1.1.1"/>
 <repository location="http://archive.eclipse.org/tracecompass/tracecompass-test-traces/repository/"/>
 </location>
 </locations>
index 15597f2ba4befd599023a2845073e62e98af8b69..e9a182e136102b7b704976af4bec36912ecac3c5 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.8"?><target name="tracecompass-eStaging" sequenceNumber="50">
+<?pde version="3.8"?><target name="tracecompass-eStaging" sequenceNumber="51">
 <locations>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
 <unit id="org.eclipse.cdt.gnu.dsf.feature.group" version="0.0.0"/>
@@ -45,7 +45,7 @@
 <repository location="http://download.eclipse.org/eclipse/updates/4.5/"/>
 </location>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
-<unit id="org.eclipse.tracecompass.testtraces.tracecompass-test-traces-ctf" version="1.0.0"/>
+<unit id="org.eclipse.tracecompass.testtraces.tracecompass-test-traces-ctf" version="1.1.1"/>
 <repository location="http://archive.eclipse.org/tracecompass/tracecompass-test-traces/repository/"/>
 </location>
 </locations>
This page took 0.029484 seconds and 5 git commands to generate.