ShrinkingLargeProgressMonitor implements LargeProgressMonitor { @Override public void worked(long workUnits) { if (workUnits < 0) throw new IllegalArgumentException("Going backwards? (Work units may not be negative)"); totalWorked += workUnits; int intUnits = (int)(totalWorked >> shift); if (intUnits > intTotalWorked) { wrapped.worked(intUnits - intTotalWorked); intTotalWorked = intUnits; } } ShrinkingLargeProgressMonitor(ProgressMonitor wrapped); @Override void subTask(String message); @Override void startTask(long totalUnits, String task); @Override void worked(long workUnits);  }
@Test public void testWorked() { TestProgressMonitor test = new TestProgressMonitor(1, 2, 3, 4); ShrinkingLargeProgressMonitor pm = new ShrinkingLargeProgressMonitor(test); pm.startTask(100, ""); pm.worked(1); test.assertEvent(1); pm.worked(2); test.assertEvent(2); pm.worked(3); test.assertEvent(3); pm.worked(4); test.assertEvent(4); test.reset(); pm.startTask(0x100000000L, ""); assertEquals("Shift", pm.shift, 2); pm.worked(1); test.assertEvent(0); pm.worked(3); test.assertEvent(1); pm.worked(8); test.assertEvent(2); pm.worked(12); test.assertEvent(3); pm.worked(16); test.assertEvent(4); }