use of com.android.tools.idea.monitor.tool.ProfilerEventListener in project android by JetBrains.
the class NetworkProfilerVisualTest method createComponentsList.
@Override
protected List<Animatable> createComponentsList() {
long startTimeUs = myDataStore.getLatestTimeUs();
Range timeCurrentRangeUs = new Range(startTimeUs - RangeScrollbar.DEFAULT_VIEW_LENGTH_US, startTimeUs);
AnimatedTimeRange animatedTimeRange = new AnimatedTimeRange(timeCurrentRangeUs, 0);
EventDispatcher<ProfilerEventListener> dummyDispatcher = EventDispatcher.create(ProfilerEventListener.class);
mySegment = new NetworkSegment(timeCurrentRangeUs, myDataStore, dummyDispatcher);
myDetailedView = new NetworkDetailedView();
myDetailedView.setVisible(false);
generateNetworkCaptureData(startTimeUs);
myCaptureSegment = new NetworkCaptureSegment(timeCurrentRangeUs, new TestNetworkCaptureModel(), httpData -> myDetailedView.setVisible(true), dummyDispatcher);
myRadioSegment = new NetworkRadioSegment(timeCurrentRangeUs, myDataStore, dummyDispatcher);
List<Animatable> animatables = new ArrayList<>();
animatables.add(animatedTimeRange);
mySegment.createComponentsList(animatables);
myCaptureSegment.createComponentsList(animatables);
myRadioSegment.createComponentsList(animatables);
animatables.add(myCaptureSegment);
return animatables;
}
use of com.android.tools.idea.monitor.tool.ProfilerEventListener in project android by JetBrains.
the class ProfilerOverviewVisualTest method populateUi.
@Override
public void populateUi(JPanel panel) {
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
JBPanel gridBagPanel = new JBPanel();
gridBagPanel.setBorder(BorderFactory.createLineBorder(AdtUiUtils.DEFAULT_BORDER_COLOR, 1));
gridBagPanel.setLayout(gbl);
// TODO create some controls.
final JPanel controls = VisualTest.createControlledPane(panel, gridBagPanel);
// Add Mock Toolbar
gbc.fill = GridBagConstraints.BOTH;
gbc.gridy = 0;
gbc.gridx = 0;
gbc.gridwidth = 4;
gbc.weightx = 0;
gbc.weighty = 0;
gridBagPanel.add(createToolbarPanel(), gbc);
// Add Selection Overlay
// TODO define sizes for x columns 0 and 1
gbc.fill = GridBagConstraints.BOTH;
gbc.gridy = 1;
gbc.gridx = 2;
gbc.gridwidth = 1;
gbc.weightx = 1;
gbc.weighty = 1;
gridBagPanel.add(mSelection, gbc);
// Add Accordion Control
gbc.gridx = 0;
gbc.gridwidth = 4;
gbc.gridy = 1;
gbc.weighty = 0;
gbc.weightx = 0;
gridBagPanel.add(mSegmentsContainer, gbc);
// Add Scrollbar
gbc.gridy = 2;
gridBagPanel.add(mScrollbar, gbc);
// TODO: fix me, currently it's throwing IllegalArgumentException, the reason is:
// EventSegment is using {@code DeviceProfilerService} which doesn't exist in visual test concept.
// Mock event segment
//BaseSegment eventSegment = new EventSegment(mTimeCurrentRange, mDataStore, ICONS, mEventDispatcher);
//setupAndRegisterSegment(eventSegment, EVENT_MIN_HEIGHT, MONITOR_PREFERRED_HEIGHT, MONITOR_MAX_HEIGHT);
// Mock monitor segments
BaseSegment networkSegment = new NetworkSegment(mTimeCurrentRange, mDataStore, mEventDispatcher);
setupAndRegisterSegment(networkSegment, 0, MONITOR_PREFERRED_HEIGHT, MONITOR_MAX_HEIGHT);
BaseSegment memorySegment = new MemorySegment(mTimeCurrentRange, mDataStore, mEventDispatcher);
setupAndRegisterSegment(memorySegment, 0, MONITOR_PREFERRED_HEIGHT, MONITOR_MAX_HEIGHT);
BaseSegment cpuSegment = new CpuUsageSegment(mTimeCurrentRange, mDataStore, mEventDispatcher);
setupAndRegisterSegment(cpuSegment, 0, MONITOR_PREFERRED_HEIGHT, MONITOR_MAX_HEIGHT);
// Timeline segment
BaseSegment timeSegment = new TimeAxisSegment(mTimeCurrentRange, mTimeAxis, mEventDispatcher);
setupAndRegisterSegment(timeSegment, TIME_AXIS_HEIGHT, TIME_AXIS_HEIGHT, TIME_AXIS_HEIGHT);
// Add left spacer
Dimension leftSpacer = new Dimension(BaseSegment.getSpacerWidth() + networkSegment.getLabelColumnWidth(), 0);
gbc.gridy = 0;
gbc.gridx = 0;
gbc.gridwidth = 2;
gbc.weightx = 0;
gbc.weighty = 0;
gridBagPanel.add(new Box.Filler(leftSpacer, leftSpacer, leftSpacer), gbc);
// Add right spacer
Dimension rightSpacerWidth = new Dimension(BaseSegment.getSpacerWidth(), 0);
Box.Filler rightSpacer = new Box.Filler(rightSpacerWidth, rightSpacerWidth, rightSpacerWidth);
gbc.gridy = 0;
gbc.gridx = 3;
gbc.gridwidth = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gridBagPanel.add(rightSpacer, gbc);
// hide right space in L1 by default.
rightSpacer.setVisible(false);
// Resize the SelectionComponent based on whether we are in L1 or L2 view.
// TODO construct/destroyed Level3 segment/elements as we expand/collapse segments
mEventDispatcher.addListener(new ProfilerEventListener() {
@Override
public void profilerExpanded(@NotNull BaseProfilerUiManager.ProfilerType profilerType) {
switch(profilerType) {
case NETWORK:
maximizeSegment(networkSegment);
break;
case CPU:
maximizeSegment(cpuSegment);
break;
case MEMORY:
maximizeSegment(memorySegment);
break;
}
rightSpacer.setVisible(true);
mResetProfilersButton.setEnabled(true);
}
@Override
public void profilersReset() {
// Sets all the components back to their preferred states.
mLayout.resetComponents();
rightSpacer.setVisible(false);
mResetProfilersButton.setEnabled(false);
backProfilersToL1();
}
private void maximizeSegment(BaseSegment segment) {
mLayout.setState(segment, AccordionLayout.AccordionState.MAXIMIZE);
segment.toggleView(true);
}
private void backProfilersToL1() {
networkSegment.toggleView(false);
cpuSegment.toggleView(false);
memorySegment.toggleView(false);
}
});
}
use of com.android.tools.idea.monitor.tool.ProfilerEventListener in project android by JetBrains.
the class CpuProfilerVisualTest method createComponentsList.
@Override
protected List<Animatable> createComponentsList() {
long startTimeUs = mDataStore.getLatestTimeUs();
Range timeCurrentRangeUs = new Range(startTimeUs - RangeScrollbar.DEFAULT_VIEW_LENGTH_US, startTimeUs);
AnimatedTimeRange animatedTimeRange = new AnimatedTimeRange(timeCurrentRangeUs, 0);
//TODO Update test data for CpuUsageSegment to be exactly what it was.
EventDispatcher<ProfilerEventListener> dummyDispatcher = EventDispatcher.create(ProfilerEventListener.class);
mCPULevel2Segment = new CpuUsageSegment(timeCurrentRangeUs, mDataStore, dummyDispatcher);
mThreadsSegment = new ThreadsSegment(timeCurrentRangeUs, mDataStore, dummyDispatcher, (threads) -> {
// TODO: show L3 segment with the charts corresponding to threads selected.
// Hide any charts corresponding to unselected threads and hide L3 segment in case no threads are selected
});
List<Animatable> animatables = new ArrayList<>();
animatables.add(animatedTimeRange);
animatables.add(mThreadsSegment);
mCPULevel2Segment.createComponentsList(animatables);
mThreadsSegment.createComponentsList(animatables);
return animatables;
}
use of com.android.tools.idea.monitor.tool.ProfilerEventListener in project android by JetBrains.
the class MemoryProfilerVisualTest method createComponentsList.
@Override
protected List<Animatable> createComponentsList() {
long startTimeUs = mDataStore.getLatestTimeUs();
Range timeCurrentRangeUs = new Range(startTimeUs - RangeScrollbar.DEFAULT_VIEW_LENGTH_US, startTimeUs);
AnimatedTimeRange animatedTimeRange = new AnimatedTimeRange(timeCurrentRangeUs, 0);
EventDispatcher<ProfilerEventListener> dummyDispatcher = EventDispatcher.create(ProfilerEventListener.class);
mSegment = new MemorySegment(timeCurrentRangeUs, mDataStore, dummyDispatcher);
mRoot = new MemoryInfoTreeNode("Root");
mDetailSegment = new MemoryDetailSegment(timeCurrentRangeUs, mRoot, dummyDispatcher);
List<Animatable> animatables = new ArrayList<>();
animatables.add(animatedTimeRange);
mSegment.createComponentsList(animatables);
mDetailSegment.createComponentsList(animatables);
// Simulate allocation data with stack frames.
mUpdateDataThread = new Thread() {
@Override
public void run() {
try {
while (true) {
updateTree(mRoot);
Thread.sleep(10);
}
} catch (InterruptedException e) {
}
}
};
mUpdateDataThread.start();
return animatables;
}
Aggregations