Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec1caf8a authored by Ling Ma's avatar Ling Ma Committed by Automerger Merge Worker
Browse files

Merge "Allow simultaneous timestamp not considered as inWindow" into tm-dev am: 9c8f6e98

parents 71aaac5e 9c8f6e98
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ public class SlidingWindowEventCounter {
    public synchronized boolean isInWindow() {
        return (mTimestampQueueMillis.size() == mNumOccurrences)
                && mTimestampQueueMillis.peekFirst()
                + mWindowSizeMillis >= mTimestampQueueMillis.peekLast();
                + mWindowSizeMillis > mTimestampQueueMillis.peekLast();
    }

    @VisibleForTesting
+3 −2
Original line number Diff line number Diff line
@@ -79,7 +79,8 @@ public class SlidingWindowEventCounterTest {
        counter = new SlidingWindowEventCounter(0, 2);
        counter.addOccurrence(mInitialTime);
        counter.addOccurrence(mInitialTime);
        assertTrue(counter.isInWindow());
        assertFalse(counter.addOccurrence(mInitialTime + 1));
        assertFalse(counter.isInWindow());
        assertFalse(counter.addOccurrence(mInitialTime));
        assertFalse(counter.addOccurrence(mInitialTime));
    }
}