@Test public void testGetProfilesWithActiveDebugSession_returnsEmptySetIfNoDebugSessions() { Project project = mock(Project.class); createMockXDebuggerManager(project, new XDebugSession[0]); Set<RunProfile> profiles = new CloudDebugProcessStateCollector().getProfilesWithActiveDebugSession(project); assertNotNull(profiles); assertThat(profiles).hasSize(0); }
/** Get all the background snapshot states. */ public List<CloudDebugProcessState> getBackgroundListeningStates() { List<CloudDebugProcessState> states = new ArrayList<CloudDebugProcessState>(); for (Project project : ProjectManager.getInstance().getOpenProjects()) { Set<RunProfile> runningProfiles = getProfilesWithActiveDebugSession(project); RunManager manager = RunManager.getInstance(project); // find all CloudDebugRunConfiguration that do not have active debug sessions but are // listening in the background for (final RunnerAndConfigurationSettings config : manager.getAllSettings()) { if (notRunningConfiguration(runningProfiles, config.getConfiguration())) { if (config.getConfiguration() instanceof CloudDebugRunConfiguration) { final CloudDebugRunConfiguration cloudConfig = (CloudDebugRunConfiguration) config.getConfiguration(); CloudDebugProcessState state = cloudConfig.getProcessState(); if (listensInBackground(state)) { states.add(state); } } } } } return states; }
@Test public void testGetProfilesWithActiveDebugSession_returnsNotStoppedSessionsWithRunProfile() { Project project = mock(Project.class); XDebugSession notStoppedSession = createMockSession(false, mock(CloudDebugRunConfiguration.class)); XDebugSession stoppedSession = createMockSession(true, mock(CloudDebugRunConfiguration.class)); XDebugSession stoppedSessionWithoutRunProfile = createMockSession(true, null); createMockXDebuggerManager( project, new XDebugSession[] {notStoppedSession, stoppedSession, stoppedSessionWithoutRunProfile}); Set<RunProfile> profiles = new CloudDebugProcessStateCollector().getProfilesWithActiveDebugSession(project); assertNotNull(profiles); assertThat(profiles).hasSize(1); }