d74b68103b8325427fac6ebce9d469ee92ade922
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
.assertNotNull
;
13 import static org
.junit
.Assert
.assertTrue
;
17 import org
.apache
.log4j
.ConsoleAppender
;
18 import org
.apache
.log4j
.Logger
;
19 import org
.apache
.log4j
.SimpleLayout
;
20 import org
.eclipse
.swtbot
.eclipse
.finder
.SWTWorkbenchBot
;
21 import org
.eclipse
.swtbot
.eclipse
.finder
.widgets
.SWTBotView
;
22 import org
.eclipse
.swtbot
.swt
.finder
.junit
.SWTBotJunit4ClassRunner
;
23 import org
.eclipse
.swtbot
.swt
.finder
.matchers
.WidgetOfType
;
24 import org
.eclipse
.swtbot
.swt
.finder
.utils
.SWTBotPreferences
;
25 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTreeItem
;
26 import org
.eclipse
.tracecompass
.internal
.lttng2
.ust
.ui
.views
.memusage
.MemoryUsageView
;
27 import org
.eclipse
.tracecompass
.testtraces
.ctf
.CtfTestTrace
;
28 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.tests
.shared
.CtfTmfTestTraceUtils
;
29 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.ConditionHelpers
;
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 int EXPECTED_NUM_SERIES
= 4;
50 private static final String UST_ID
= "org.eclipse.linuxtools.lttng2.ust.tracetype";
52 private static final String PROJECT_NAME
= "TestForMemory";
54 /** The Log4j logger instance. */
55 private static final Logger fLogger
= Logger
.getRootLogger();
56 private static SWTWorkbenchBot fBot
;
62 public static void init() {
63 SWTBotUtils
.initialize();
65 Thread
.currentThread().setName("SWTBot Thread"); // for the debugger
66 /* set up for swtbot */
67 SWTBotPreferences
.TIMEOUT
= 20000; /* 20 second timeout */
68 fLogger
.addAppender(new ConsoleAppender(new SimpleLayout()));
69 fBot
= new SWTWorkbenchBot();
71 SWTBotUtils
.closeView("welcome", fBot
);
73 SWTBotUtils
.switchToTracingPerspective();
75 /* finish waiting for eclipse to load */
76 SWTBotUtils
.waitForJobs();
80 * Open a trace in an editor
83 public void beforeTest() {
84 SWTBotUtils
.createProject(PROJECT_NAME
);
85 SWTBotTreeItem treeItem
= SWTBotUtils
.selectTracesFolder(fBot
, PROJECT_NAME
);
86 assertNotNull(treeItem
);
87 final CtfTestTrace cygProfile
= CtfTestTrace
.MEMORY_ANALYSIS
;
88 final File file
= new File(CtfTmfTestTraceUtils
.getTrace(cygProfile
).getPath());
89 SWTBotUtils
.openTrace(PROJECT_NAME
, file
.getAbsolutePath(), UST_ID
);
90 SWTBotUtils
.openView(MemoryUsageView
.ID
);
91 SWTBotUtils
.waitForJobs();
98 public void tearDown() {
99 fBot
.closeAllEditors();
100 SWTBotUtils
.deleteProject(PROJECT_NAME
, fBot
);
104 * Test if Memory Usage is populated
107 public void testOpenMemoryUsage() {
108 SWTBotView viewBot
= fBot
.viewById(MemoryUsageView
.ID
);
111 // Do some basic validation
112 Matcher
<Chart
> matcher
= WidgetOfType
.widgetOfType(Chart
.class);
113 Chart chart
= viewBot
.bot().widget(matcher
);
115 // Verify that the chart has 4 series
116 fBot
.waitUntil(ConditionHelpers
.numberOfSeries(chart
, EXPECTED_NUM_SERIES
));
118 ISeriesSet seriesSet
= chart
.getSeriesSet();
119 ISeries
[] series
= seriesSet
.getSeries();
120 // Verify that each series is a ILineSeries
121 for (int i
= 0; i
< series
.length
; i
++) {
122 assertTrue(series
[i
] instanceof ILineSeries
);
This page took 0.03345 seconds and 4 git commands to generate.