@NotNull @VisibleForTesting Set<RunProfile> getProfilesWithActiveDebugSession(Project project) { Set<RunProfile> debuggingProfiles = new HashSet<RunProfile>(); XDebuggerManager debugManager = XDebuggerManager.getInstance(project); for (XDebugSession session : debugManager.getDebugSessions()) { if (notStoppedAndHasRunProfile(session)) { debuggingProfiles.add(session.getRunProfile()); } } return debuggingProfiles; }
private List<CloudDebugProcess> getActiveDebugProcesses(Project project) { List<CloudDebugProcess> processes = Lists.newArrayList(); for (XDebugSession session : XDebuggerManager.getInstance(project).getDebugSessions()) { if (session.getDebugProcess() instanceof CloudDebugProcess) { processes.add((CloudDebugProcess) session.getDebugProcess()); } } return processes; } }
void createMockXDebuggerManager(Project project, XDebugSession[] value) { XDebuggerManager debuggerManager = mock(XDebuggerManager.class); when(debuggerManager.getDebugSessions()).thenReturn(value); when(project.getComponent(XDebuggerManager.class)).thenReturn(debuggerManager); }
private Project createProject( int inProgressDebugSessions, int backgroundListeningDebugsSessions, int notListeningDebugSessions) { XDebuggerManager debuggerManager = mock(XDebuggerManager.class); XDebugSession[] debugSessions = new XDebugSession[inProgressDebugSessions]; List<RunnerAndConfigurationSettings> allRunnerSettings = new ArrayList<RunnerAndConfigurationSettings>(); for (int i = 0; i < inProgressDebugSessions; i++) { XDebugSession debugSession = createInProgressDebugSettings(allRunnerSettings); debugSessions[i] = debugSession; } when(debuggerManager.getDebugSessions()).thenReturn(debugSessions); applicationContainer.unregisterComponent(XDebuggerManager.class.getName()); registerService(XDebuggerManager.class, debuggerManager); for (int i = 0; i < backgroundListeningDebugsSessions; i++) { createBackgroundListeningDebugSettings(allRunnerSettings); } for (int i = 0; i < notListeningDebugSessions; i++) { createNotListeningNotActiveSettings(allRunnerSettings); } RunManager runManager = mock(RunManager.class); when(runManager.getAllSettings()).thenReturn(allRunnerSettings); applicationContainer.unregisterComponent(RunManager.class.getName()); registerService(RunManager.class, runManager); return project; }