5a313736891b6c180eb30cff8e9efdd799de365d
1 /*******************************************************************************
2 * Copyright (c) 2015 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.lttng2
.ust
.ui
.swtbot
.tests
;
12 import static org
.junit
.Assert
.assertEquals
;
13 import static org
.junit
.Assert
.assertNotNull
;
14 import static org
.junit
.Assert
.assertTrue
;
18 import org
.apache
.log4j
.ConsoleAppender
;
19 import org
.apache
.log4j
.Logger
;
20 import org
.apache
.log4j
.SimpleLayout
;
21 import org
.eclipse
.swtbot
.eclipse
.finder
.SWTWorkbenchBot
;
22 import org
.eclipse
.swtbot
.eclipse
.finder
.widgets
.SWTBotView
;
23 import org
.eclipse
.swtbot
.swt
.finder
.junit
.SWTBotJunit4ClassRunner
;
24 import org
.eclipse
.swtbot
.swt
.finder
.matchers
.WidgetOfType
;
25 import org
.eclipse
.swtbot
.swt
.finder
.utils
.SWTBotPreferences
;
26 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTreeItem
;
27 import org
.eclipse
.tracecompass
.internal
.lttng2
.ust
.ui
.views
.memusage
.MemoryUsageView
;
28 import org
.eclipse
.tracecompass
.testtraces
.ctf
.CtfTestTrace
;
29 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.tests
.shared
.CtfTmfTestTraceUtils
;
30 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.SWTBotUtils
;
31 import org
.hamcrest
.Matcher
;
32 import org
.junit
.After
;
33 import org
.junit
.Before
;
34 import org
.junit
.BeforeClass
;
35 import org
.junit
.Test
;
36 import org
.junit
.runner
.RunWith
;
37 import org
.swtchart
.Chart
;
38 import org
.swtchart
.ILineSeries
;
39 import org
.swtchart
.ISeries
;
40 import org
.swtchart
.ISeriesSet
;
43 * Test for the Memory Usage view in trace compass
45 @RunWith(SWTBotJunit4ClassRunner
.class)
46 public class MemoryUsageViewTest
{
48 private static final String UST_ID
= "org.eclipse.linuxtools.lttng2.ust.tracetype";
50 private static final String PROJECT_NAME
= "TestForMemory";
52 /** The Log4j logger instance. */
53 private static final Logger fLogger
= Logger
.getRootLogger();
54 private static SWTWorkbenchBot fBot
;
60 public static void init() {
61 SWTBotUtils
.initialize();
63 Thread
.currentThread().setName("SWTBot Thread"); // for the debugger
64 /* set up for swtbot */
65 SWTBotPreferences
.TIMEOUT
= 20000; /* 20 second timeout */
66 fLogger
.addAppender(new ConsoleAppender(new SimpleLayout()));
67 fBot
= new SWTWorkbenchBot();
69 SWTBotUtils
.closeView("welcome", fBot
);
71 SWTBotUtils
.switchToTracingPerspective();
73 /* finish waiting for eclipse to load */
74 SWTBotUtils
.waitForJobs();
78 * Open a trace in an editor
81 public void beforeTest() {
82 SWTBotUtils
.createProject(PROJECT_NAME
);
83 SWTBotTreeItem treeItem
= SWTBotUtils
.selectTracesFolder(fBot
, PROJECT_NAME
);
84 assertNotNull(treeItem
);
85 final CtfTestTrace cygProfile
= CtfTestTrace
.MEMORY_ANALYSIS
;
86 final File file
= new File(CtfTmfTestTraceUtils
.getTrace(cygProfile
).getPath());
87 SWTBotUtils
.openTrace(PROJECT_NAME
, file
.getAbsolutePath(), UST_ID
);
88 SWTBotUtils
.openView(MemoryUsageView
.ID
);
89 SWTBotUtils
.waitForJobs();
96 public void tearDown() {
97 fBot
.closeAllEditors();
98 SWTBotUtils
.deleteProject(PROJECT_NAME
, fBot
);
102 * Test if Memory Usage is populated
105 public void testOpenMemoryUsage() {
106 SWTBotView viewBot
= fBot
.viewById(MemoryUsageView
.ID
);
109 // Do some basic validation
110 Matcher
<Chart
> matcher
= WidgetOfType
.widgetOfType(Chart
.class);
111 Chart chart
= viewBot
.bot().widget(matcher
);
112 ISeriesSet seriesSet
= chart
.getSeriesSet();
113 assertNotNull(seriesSet
);
114 ISeries
[] series
= seriesSet
.getSeries();
115 assertNotNull(series
);
117 // Verify that the chart has 4 series
118 assertEquals(4, series
.length
);
119 // Verify that each series is a ILineSeries
120 for (int i
= 0; i
< series
.length
; i
++) {
121 assertTrue(series
[i
] instanceof ILineSeries
);
This page took 0.03503 seconds and 4 git commands to generate.