@GwtIncompatible // threads public void testOverflowTimeout() throws Exception { // First, sanity check that naive multiplication would really overflow to a negative number: long nanosPerSecond = NANOSECONDS.convert(1, SECONDS); assertThat(nanosPerSecond * Long.MAX_VALUE).isLessThan(0L); // Check that we wait long enough anyway (presumably as long as MAX_VALUE nanos): TimedWaiterThread waiter = new TimedWaiterThread(future, Long.MAX_VALUE, SECONDS); waiter.start(); waiter.awaitWaiting(); future.set(1); waiter.join(); }
public void testCountOverflow_doesNotThrow() { PairedStatsAccumulator accumulator = new PairedStatsAccumulator(); accumulator.add(ONE_VALUE, OTHER_ONE_VALUE); for (int power = 1; power < Long.SIZE - 1; power++) { accumulator.addAll(accumulator.snapshot()); } // Should overflow without throwing. accumulator.addAll(accumulator.snapshot()); assertThat(accumulator.count()).isLessThan(0L); }
public void testCountOverflow_doesNotThrow() { StatsAccumulator accumulator = new StatsAccumulator(); accumulator.add(ONE_VALUE); for (int power = 1; power < Long.SIZE - 1; power++) { accumulator.addAll(accumulator.snapshot()); } // Should overflow without throwing. accumulator.addAll(accumulator.snapshot()); assertThat(accumulator.count()).isLessThan(0L); }
private void assertFirstSampleAfterSeekContainTargetSeekTime( FakeTrackOutput trackOutput, long seekTimeUs, int firstSampleIndexAfterSeek) { long outputSampleTimeUs = trackOutput.getSampleTimeUs(firstSampleIndexAfterSeek); int expectedSampleIndex = findOutputSampleInExpectedOutput(trackOutput.getSampleData(firstSampleIndexAfterSeek)); // Assert that after seeking, the first sample written to output exists in the sample list assertThat(expectedSampleIndex).isNotEqualTo(-1); // Assert that the timestamp output for first sample after seek is near the seek point. // For ADTS seeking, unfortunately we can't guarantee exact sample seeking, since most ADTS // stream use VBR. assertThat(Math.abs(outputSampleTimeUs - seekTimeUs)).isLessThan(DELTA_TIMESTAMP_THRESHOLD_US); assertThat( Math.abs(outputSampleTimeUs - expectedTrackOutput.getSampleTimeUs(expectedSampleIndex))) .isLessThan(DELTA_TIMESTAMP_THRESHOLD_US); trackOutput.assertSample( firstSampleIndexAfterSeek, expectedTrackOutput.getSampleData(expectedSampleIndex), outputSampleTimeUs, expectedTrackOutput.getSampleFlags(expectedSampleIndex), expectedTrackOutput.getSampleCryptoData(expectedSampleIndex)); }
private void assertFirstFrameAfterSeekContainTargetSeekTime( FakeTrackOutput trackOutput, long seekTimeUs, int firstFrameIndexAfterSeek) { long outputSampleTimeUs = trackOutput.getSampleTimeUs(firstFrameIndexAfterSeek); int expectedSampleIndex = findOutputFrameInExpectedOutput(trackOutput.getSampleData(firstFrameIndexAfterSeek)); // Assert that after seeking, the first sample frame written to output exists in the sample list assertThat(expectedSampleIndex).isNotEqualTo(-1); // Assert that the timestamp output for first sample after seek is near the seek point. // For Ts seeking, unfortunately we can't guarantee exact frame seeking, since PID timestamp is // not too reliable. assertThat(Math.abs(outputSampleTimeUs - seekTimeUs)).isLessThan(MAXIMUM_TIMESTAMP_DELTA_US); // Assert that the timestamp output for first sample after seek is near the actual sample // at seek point. // Note that the timestamp output for first sample after seek might *NOT* be equal to the // timestamp of that same sample when reading from the beginning, because if first timestamp in // the stream was not read before the seek, then the timestamp of the first sample after the // seek is just approximated from the seek point. assertThat( Math.abs(outputSampleTimeUs - expectedTrackOutput.getSampleTimeUs(expectedSampleIndex))) .isLessThan(MAXIMUM_TIMESTAMP_DELTA_US); trackOutput.assertSample( firstFrameIndexAfterSeek, expectedTrackOutput.getSampleData(expectedSampleIndex), outputSampleTimeUs, expectedTrackOutput.getSampleFlags(expectedSampleIndex), expectedTrackOutput.getSampleCryptoData(expectedSampleIndex)); }
.isLessThan(DELTA_TIMESTAMP_THRESHOLD_US); .isLessThan(DELTA_TIMESTAMP_THRESHOLD_US); trackOutput.assertSample( firstFrameIndexAfterSeek,
.getMinSizeConfigurationMap() .get(SizeConfiguration.getDefaultInstance())) .isLessThan(compressedApkSize); assertThat(configurationSizes.getMaxSizeConfigurationMap().keySet()) .containsExactly(SizeConfiguration.getDefaultInstance());
@GwtIncompatible // threads public void testOverflowTimeout() throws Exception { // First, sanity check that naive multiplication would really overflow to a negative number: long nanosPerSecond = NANOSECONDS.convert(1, SECONDS); assertThat(nanosPerSecond * Long.MAX_VALUE).isLessThan(0L); // Check that we wait long enough anyway (presumably as long as MAX_VALUE nanos): TimedWaiterThread waiter = new TimedWaiterThread(future, Long.MAX_VALUE, SECONDS); waiter.start(); waiter.awaitWaiting(); future.set(1); waiter.join(); }
/** * Tests the actual elapsed time. */ @Test public void testRealTime() { getModel().register(new LimitingTickListener(getModel(), 3)); final long start = System.nanoTime(); getModel().start(); final long duration = System.nanoTime() - start;// - Realtime.STARTUP_DELAY; // duration should be somewhere between 200 and 300 ms assertThat(duration).isAtLeast(200000000L); assertThat(duration).isLessThan(300000000L); assertThat(getModel().getCurrentTime()).isEqualTo(300); assertThat(getModel().isExecutorAlive()).isFalse(); }
public void testCountOverflow_doesNotThrow() { PairedStatsAccumulator accumulator = new PairedStatsAccumulator(); accumulator.add(ONE_VALUE, OTHER_ONE_VALUE); for (int power = 1; power < Long.SIZE - 1; power++) { accumulator.addAll(accumulator.snapshot()); } // Should overflow without throwing. accumulator.addAll(accumulator.snapshot()); assertThat(accumulator.count()).isLessThan(0L); }
public void testCountOverflow_doesNotThrow() { StatsAccumulator accumulator = new StatsAccumulator(); accumulator.add(ONE_VALUE); for (int power = 1; power < Long.SIZE - 1; power++) { accumulator.addAll(accumulator.snapshot()); } // Should overflow without throwing. accumulator.addAll(accumulator.snapshot()); assertThat(accumulator.count()).isLessThan(0L); }