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
.eclipse
.tracecompass
.tmf
.ui
.tests
.shared
.WaitUtils
;
32 import org
.hamcrest
.Matcher
;
33 import org
.junit
.After
;
34 import org
.junit
.Before
;
35 import org
.junit
.BeforeClass
;
36 import org
.junit
.Test
;
37 import org
.junit
.runner
.RunWith
;
38 import org
.swtchart
.Chart
;
39 import org
.swtchart
.ILineSeries
;
40 import org
.swtchart
.ISeries
;
41 import org
.swtchart
.ISeriesSet
;
44 * Test for the Memory Usage view in trace compass
46 @RunWith(SWTBotJunit4ClassRunner
.class)
47 public class MemoryUsageViewTest
{
49 private static final int EXPECTED_NUM_SERIES
= 4;
51 private static final String UST_ID
= "org.eclipse.linuxtools.lttng2.ust.tracetype";
53 private static final String PROJECT_NAME
= "TestForMemory";
55 /** The Log4j logger instance. */
56 private static final Logger fLogger
= Logger
.getRootLogger();
57 private static SWTWorkbenchBot fBot
;
63 public static void init() {
64 SWTBotUtils
.initialize();
66 Thread
.currentThread().setName("SWTBot Thread"); // for the debugger
67 /* set up for swtbot */
68 SWTBotPreferences
.TIMEOUT
= 20000; /* 20 second timeout */
69 fLogger
.addAppender(new ConsoleAppender(new SimpleLayout()));
70 fBot
= new SWTWorkbenchBot();
72 SWTBotUtils
.closeView("welcome", fBot
);
74 SWTBotUtils
.switchToTracingPerspective();
76 /* finish waiting for eclipse to load */
77 WaitUtils
.waitForJobs();
81 * Open a trace in an editor
84 public void beforeTest() {
85 SWTBotUtils
.createProject(PROJECT_NAME
);
86 SWTBotTreeItem treeItem
= SWTBotUtils
.selectTracesFolder(fBot
, PROJECT_NAME
);
87 assertNotNull(treeItem
);
88 final CtfTestTrace cygProfile
= CtfTestTrace
.MEMORY_ANALYSIS
;
89 final File file
= new File(CtfTmfTestTraceUtils
.getTrace(cygProfile
).getPath());
90 CtfTmfTestTraceUtils
.dispose(cygProfile
);
91 SWTBotUtils
.openTrace(PROJECT_NAME
, file
.getAbsolutePath(), UST_ID
);
92 SWTBotUtils
.openView(MemoryUsageView
.ID
);
93 WaitUtils
.waitForJobs();
100 public void tearDown() {
101 fBot
.closeAllEditors();
102 SWTBotUtils
.deleteProject(PROJECT_NAME
, fBot
);
106 * Test if Memory Usage is populated
109 public void testOpenMemoryUsage() {
110 SWTBotView viewBot
= fBot
.viewById(MemoryUsageView
.ID
);
113 // Do some basic validation
114 Matcher
<Chart
> matcher
= WidgetOfType
.widgetOfType(Chart
.class);
115 Chart chart
= viewBot
.bot().widget(matcher
);
117 // Verify that the chart has 4 series
118 fBot
.waitUntil(ConditionHelpers
.numberOfSeries(chart
, EXPECTED_NUM_SERIES
));
120 ISeriesSet seriesSet
= chart
.getSeriesSet();
121 ISeries
[] series
= seriesSet
.getSeries();
122 // Verify that each series is a ILineSeries
123 for (int i
= 0; i
< series
.length
; i
++) {
124 assertTrue(series
[i
] instanceof ILineSeries
);
This page took 0.033118 seconds and 5 git commands to generate.