@VisibleForTesting boolean listensInBackground(CloudDebugProcessState state) { return state != null && state.isListenInBackground(); } }
private List<CloudDebugProcessState> getBackgroundDebugStates(Project project) { List<CloudDebugProcessState> states = Lists.newArrayList(); RunManager manager = RunManager.getInstance(project); for (final RunnerAndConfigurationSettings config : manager.getAllSettings()) { if (config.getConfiguration() instanceof CloudDebugRunConfiguration) { final CloudDebugRunConfiguration cloudConfig = (CloudDebugRunConfiguration) config.getConfiguration(); CloudDebugProcessState processState = cloudConfig.getProcessState(); if (processState != null && processState.isListenInBackground()) { states.add(processState); } } } return states; }
@Test public void testPollForChanges_firesNotificationOnIOException() throws IOException { cloudDebugProcessState.setListenInBackground(true); cloudDebugProcessState.setUserEmail(FAKE_USER_EMAIL); cloudDebugProcessState.setDebuggeeId(FAKE_DEBUGGEE_ID); cloudDebugProcessState.setProject(getProject()); setupCloudDebuggerBackendMockWithException(FAKE_USER_EMAIL, new IOException()); cloudDebugGlobalPoller.pollForChanges(cloudDebugProcessState); assertFalse(cloudDebugProcessState.isListenInBackground()); verifyNotificationFired(); }
@Test public void testPollForChanges_firesNotificationIfNoDebugClientObtained() { cloudDebugProcessState.setListenInBackground(true); cloudDebugProcessState.setProject(getProject()); cloudDebugGlobalPoller.pollForChanges(cloudDebugProcessState); assertFalse(cloudDebugProcessState.isListenInBackground()); verifyNotificationFired(); }
@Test public void testGetBackgroundListeningStates_withMultipleProjects() { int runningSessions = 1; int listeningSessions = 2; int notListeningSessions = 3; Project project1 = createProject(runningSessions, listeningSessions, notListeningSessions); Project project2 = createProject(runningSessions, listeningSessions, notListeningSessions); createMockProjectManagerWithProjects(new Project[] {project1, project2}); List<CloudDebugProcessState> backgroundListeningStates = new CloudDebugProcessStateCollector().getBackgroundListeningStates(); assertNotNull(backgroundListeningStates); assertThat(backgroundListeningStates).hasSize(2 * listeningSessions); for (CloudDebugProcessState state : backgroundListeningStates) { assertTrue(state.isListenInBackground()); } }
final Debugger client = CloudDebuggerClient.getShortTimeoutClient(state); if (client == null) { if (state.isListenInBackground()) {