public long next() {
        final long duration;
        if (mDurations == null) {
            duration = mDuration;
        } else {
            duration = mDurations[mIndex];
            if (mIndex < mDurations.length - 1) {
                mIndex++;
            }
        }
        mNextTime = now() + duration;
        return duration;
    }
@Test
    public void testDelayMulti() {
        final long[] millis = new long[]{500, 600, 800, 1000};
        final long lastDuration = millis[millis.length - 1];
        long next;
        final Delay delay = new Delay(millis);
        for (int i = 0; i < millis.length; i++) {
            check(delay, millis[i]);
            next = delay.next();
            Assert.assertEquals(i < millis.length - 1 ? millis[i + 1] : lastDuration, next);
        }
        check(delay, lastDuration);
        next = delay.next();
        Assert.assertEquals(lastDuration, next);
        check(delay, lastDuration);
    }