CpuProfilerStage extends StreamingStage implements CodeNavigator.Listener { @Nullable public CpuCapture getCapture() { return myCaptureModel.getCapture(); } CpuProfilerStage(@NotNull StudioProfilers profilers);  CpuProfilerStage(@NotNull StudioProfilers profilers, @Nullable File importedTrace); @VisibleForTesting  CpuProfilerStage(@NotNull StudioProfilers profilers, @Nullable File importedTrace, @NotNull CpuCaptureParser captureParser); boolean isImportTraceMode(); boolean hasUserUsedCpuCapture(); @NotNull RangeSelectionModel getRangeSelectionModel(); @NotNull EaseOutModel getInstructionsEaseOutModel(); AxisComponentModel getCpuUsageAxis(); AxisComponentModel getThreadCountAxis(); AxisComponentModel getTimeAxisGuide(); DetailedCpuUsage getCpuUsage(); CpuStageLegends getLegends(); DurationDataModel<CpuTraceInfo> getTraceDurations(); String getName(); EventMonitor getEventMonitor(); @NotNull CpuProfilerConfigModel getProfilerConfigModel(); @Override void enter(); @Override void exit(); @NotNull UpdatableManager getUpdatableManager(); AspectModel<CpuProfilerAspect> getAspect(); void toggleCapturing(); void startCapturing(); long getCaptureStartTimeNs(); long getCaptureStopTimeNs(); @NotNull TraceIdsIterator getTraceIdsIterator(); @NotNull CpuCaptureParser getCaptureParser(); long currentTimeNs(); @VisibleForTesting void setCapture(@Nullable CpuCapture capture); void setAndSelectCapture(long traceId); @VisibleForTesting void setAndSelectCapture(@NotNull CpuCapture capture); int getSelectedThread(); void setSelectedThread(int id); @NotNull List<ClockType> getClockTypes(); @NotNull ClockType getClockType(); void setClockType(@NotNull ClockType clockType); @Nullable CpuCapture getCapture(); @NotNull CaptureState getCaptureState(); @NotNull TraceInitiationType getCaptureInitiationType(); void setCaptureState(@NotNull CaptureState captureState); @NotNull FilterResult applyCaptureFilter(@NotNull Filter filter); boolean isApiInitiatedTracingInProgress(); @NotNull CpuTraceDataSeries getCpuTraceDataSeries(); @NotNull CpuThreadsModel getThreadStates(); @NotNull CpuKernelModel getCpuKernelModel(); @NotNull CpuFramesModel getFramesModel(); @NotNull CaptureModel getCaptureModel(); void setCaptureDetails(@Nullable CaptureDetails.Type type); @Nullable CaptureDetails getCaptureDetails(); @Override void onNavigated(@NotNull CodeLocation location); static final int CPU_ART_STOP_TIMEOUT_SEC; }
@Test public void selectARangeWithNoCapturesShouldKeepCurrentCaptureSelected() throws InterruptedException, IOException { assertThat(myStage.getCapture()).isNull(); CpuProfilerTestUtils.captureSuccessfully(myStage, myCpuService, myTransportService, CpuProfilerTestUtils.readValidTrace()); assertThat(myStage.getCapture()).isNotNull(); CpuCapture capture = myStage.getCapture(); Range selectionRange = myStage.getTimeline().getSelectionRange(); selectionRange.set(capture.getRange().getMin() - 20, capture.getRange().getMin() - 10); assertThat(myStage.getCapture()).isEqualTo(capture); }