private boolean isNewlySelected(Breakpoint breakpoint) { return process.getCurrentSnapshot() == null || !process.getCurrentSnapshot().getId().equals(breakpoint.getId()); }
@VisibleForTesting int getSelection() { final List<Breakpoint> breakpointList = process.getCurrentBreakpointList(); int selection = -1; if (breakpointList != null) { for (int i = 0; i < breakpointList.size(); i++) { Breakpoint snapshot = process.getCurrentSnapshot(); if (snapshot != null && breakpointList.get(i).getId().equals(snapshot.getId())) { selection = i; break; } } } return selection; }
@Test public void testOnBreakpointListChanged() throws InterruptedException { CloudDebugHistoricalSnapshots snapshots = new CloudDebugHistoricalSnapshots(handler); Breakpoint bp1 = new Breakpoint(); bp1.setId("an ID"); bp1.setFinalTime("2015-08-22T05:23:34.123Z"); bp1.setIsFinalState(true); SourceLocation location = new SourceLocation(); location.setPath("foo/bar/baz"); location.setLine(12); bp1.setLocation(location); List<Breakpoint> breakpoints = new ArrayList<Breakpoint>(); breakpoints.add(bp1); Mockito.when(mockProcess.getCurrentBreakpointList()).thenReturn(breakpoints); Mockito.when(mockProcess.getCurrentSnapshot()).thenReturn(bp1); CloudBreakpointHandler breakpointHandler = Mockito.mock(CloudBreakpointHandler.class); Mockito.when(mockProcess.getBreakpointHandler()).thenReturn(breakpointHandler); runModelSetter(snapshots); Assert.assertEquals(0, snapshots.table.getSelectedRow()); }
Mockito.when(mockProcess.getCurrentSnapshot()).thenReturn(bp1); runModelSetter(snapshots); Assert.assertEquals(0, snapshots.table.getSelectedRow()); Mockito.when(mockProcess.getCurrentSnapshot()).thenReturn(bp2); runModelSetter(snapshots); Assert.assertEquals(1, snapshots.table.getSelectedRow());