From 7a114cb3746f832c671112aebcba4b1faebce036 Mon Sep 17 00:00:00 2001 From: eguven Date: Wed, 7 Nov 2018 02:29:53 -0800 Subject: [PATCH] Uncomment VisibleForTesting annotations ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=220432564 --- .../exoplayer2/ext/ima/ImaAdsLoader.java | 5 ++-- .../extractor/ogg/DefaultOggSeeker.java | 27 +++++++++---------- .../exoplayer2/extractor/ogg/OggPacket.java | 7 ++--- .../extractor/ogg/VorbisReader.java | 15 ++++++----- .../exoplayer2/text/ttml/TtmlSubtitle.java | 5 ++-- .../upstream/cache/CachedContentIndex.java | 3 ++- .../ui/spherical/SphericalSurfaceView.java | 3 ++- .../exoplayer2/ui/spherical/TouchTracker.java | 3 ++- 8 files changed, 37 insertions(+), 31 deletions(-) diff --git a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java index 3be28e1b84..40950bceef 100644 --- a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java +++ b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java @@ -21,6 +21,7 @@ import android.os.Looper; import android.os.SystemClock; import android.support.annotation.IntDef; import android.support.annotation.Nullable; +import android.support.annotation.VisibleForTesting; import android.view.ViewGroup; import com.google.ads.interactivemedia.v3.api.Ad; import com.google.ads.interactivemedia.v3.api.AdDisplayContainer; @@ -206,7 +207,7 @@ public final class ImaAdsLoader return this; } - // @VisibleForTesting + @VisibleForTesting /* package */ Builder setImaFactory(ImaFactory imaFactory) { this.imaFactory = Assertions.checkNotNull(imaFactory); return this; @@ -1346,7 +1347,7 @@ public final class ImaAdsLoader } /** Factory for objects provided by the IMA SDK. */ - // @VisibleForTesting + @VisibleForTesting /* package */ interface ImaFactory { /** @see ImaSdkSettings */ ImaSdkSettings createImaSdkSettings(); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java b/library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java index 93ed00a05b..d251dc1d5d 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java @@ -15,6 +15,7 @@ */ package com.google.android.exoplayer2.extractor.ogg; +import android.support.annotation.VisibleForTesting; import com.google.android.exoplayer2.ParserException; import com.google.android.exoplayer2.extractor.ExtractorInput; import com.google.android.exoplayer2.extractor.SeekMap; @@ -26,10 +27,8 @@ import java.io.IOException; /** Seeks in an Ogg stream. */ /* package */ final class DefaultOggSeeker implements OggSeeker { - //@VisibleForTesting - public static final int MATCH_RANGE = 72000; - //@VisibleForTesting - public static final int MATCH_BYTE_RANGE = 100000; + @VisibleForTesting public static final int MATCH_RANGE = 72000; + @VisibleForTesting public static final int MATCH_BYTE_RANGE = 100000; private static final int DEFAULT_OFFSET = 30000; private static final int STATE_SEEK_TO_END = 0; @@ -133,7 +132,7 @@ import java.io.IOException; return totalGranules != 0 ? new OggSeekMap() : null; } - //@VisibleForTesting + @VisibleForTesting public void resetSeeking() { start = startPosition; end = endPosition; @@ -150,12 +149,12 @@ import java.io.IOException; * * @param targetGranule the target granule position to seek to. * @param input the {@link ExtractorInput} to read from. - * @return the position to seek the {@link ExtractorInput} to for a next call or - * -(currentGranule + 2) if it's close enough to skip to the target page. + * @return the position to seek the {@link ExtractorInput} to for a next call or -(currentGranule + * + 2) if it's close enough to skip to the target page. * @throws IOException thrown if reading from the input fails. * @throws InterruptedException thrown if interrupted while reading from the input. */ - //@VisibleForTesting + @VisibleForTesting public long getNextSeekPosition(long targetGranule, ExtractorInput input) throws IOException, InterruptedException { if (start == end) { @@ -250,7 +249,7 @@ import java.io.IOException; * @throws InterruptedException If the thread is interrupted. * @throws EOFException If the next page can't be found before the end of the input. */ - // @VisibleForTesting + @VisibleForTesting void skipToNextPage(ExtractorInput input) throws IOException, InterruptedException { if (!skipToNextPage(input, endPosition)) { // Not found until eof. @@ -267,7 +266,7 @@ import java.io.IOException; * @throws IOException thrown if peeking/reading from the input fails. * @throws InterruptedException thrown if interrupted while peeking/reading from the input. */ - // @VisibleForTesting + @VisibleForTesting boolean skipToNextPage(ExtractorInput input, long limit) throws IOException, InterruptedException { limit = Math.min(limit + 3, endPosition); @@ -307,7 +306,7 @@ import java.io.IOException; * @throws IOException If reading from the input fails. * @throws InterruptedException If the thread is interrupted. */ - // @VisibleForTesting + @VisibleForTesting long readGranuleOfLastPage(ExtractorInput input) throws IOException, InterruptedException { skipToNextPage(input); pageHeader.reset(); @@ -319,8 +318,8 @@ import java.io.IOException; } /** - * Skips to the position of the start of the page containing the {@code targetGranule} and - * returns the granule of the page previous to the target page. + * Skips to the position of the start of the page containing the {@code targetGranule} and returns + * the granule of the page previous to the target page. * * @param input the {@link ExtractorInput} to read from. * @param targetGranule the target granule. @@ -331,7 +330,7 @@ import java.io.IOException; * @throws IOException thrown if reading from the input fails. * @throws InterruptedException thrown if interrupted while reading from the input. */ - //@VisibleForTesting + @VisibleForTesting long skipToPageOfGranule(ExtractorInput input, long targetGranule, long currentGranule) throws IOException, InterruptedException { pageHeader.populate(input, false); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPacket.java b/library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPacket.java index 482f0c5021..ca79c838de 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPacket.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPacket.java @@ -15,6 +15,7 @@ */ package com.google.android.exoplayer2.extractor.ogg; +import android.support.annotation.VisibleForTesting; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.extractor.ExtractorInput; import com.google.android.exoplayer2.util.Assertions; @@ -103,14 +104,14 @@ import java.util.Arrays; /** * An OGG Packet may span multiple pages. Returns the {@link OggPageHeader} of the last page read, * or an empty header if the packet has yet to be populated. - *

- * Note that the returned {@link OggPageHeader} is mutable and may be updated during subsequent + * + *

Note that the returned {@link OggPageHeader} is mutable and may be updated during subsequent * calls to {@link #populate(ExtractorInput)}. * * @return the {@code PageHeader} of the last page read or an empty header if the packet has yet * to be populated. */ - //@VisibleForTesting + @VisibleForTesting public OggPageHeader getPageHeader() { return pageHeader; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/VorbisReader.java b/library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/VorbisReader.java index 147ad5a20b..3c62f7a824 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/VorbisReader.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/VorbisReader.java @@ -15,6 +15,7 @@ */ package com.google.android.exoplayer2.extractor.ogg; +import android.support.annotation.VisibleForTesting; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.ParserException; import com.google.android.exoplayer2.extractor.ogg.VorbisUtil.Mode; @@ -107,7 +108,7 @@ import java.util.ArrayList; return true; } - //@VisibleForTesting + @VisibleForTesting /* package */ VorbisSetup readSetupHeaders(ParsableByteArray scratch) throws IOException { if (vorbisIdHeader == null) { @@ -133,22 +134,22 @@ import java.util.ArrayList; } /** - * Reads an int of {@code length} bits from {@code src} starting at - * {@code leastSignificantBitIndex}. + * Reads an int of {@code length} bits from {@code src} starting at {@code + * leastSignificantBitIndex}. * * @param src the {@code byte} to read from. * @param length the length in bits of the int to read. * @param leastSignificantBitIndex the index of the least significant bit of the int to read. * @return the int value read. */ - //@VisibleForTesting + @VisibleForTesting /* package */ static int readBits(byte src, int length, int leastSignificantBitIndex) { return (src >> leastSignificantBitIndex) & (255 >>> (8 - length)); } - //@VisibleForTesting - /* package */ static void appendNumberOfSamples(ParsableByteArray buffer, - long packetSampleCount) { + @VisibleForTesting + /* package */ static void appendNumberOfSamples( + ParsableByteArray buffer, long packetSampleCount) { buffer.setLimit(buffer.limit() + 4); // The vorbis decoder expects the number of samples in the packet diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlSubtitle.java b/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlSubtitle.java index 50916aa841..2ac1427e91 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlSubtitle.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlSubtitle.java @@ -15,6 +15,7 @@ */ package com.google.android.exoplayer2.text.ttml; +import android.support.annotation.VisibleForTesting; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.Subtitle; @@ -58,7 +59,7 @@ import java.util.Map; return eventTimesUs[index]; } - /* @VisibleForTesting */ + @VisibleForTesting /* package */ TtmlNode getRoot() { return root; } @@ -68,7 +69,7 @@ import java.util.Map; return root.getCues(timeUs, globalStyles, regionMap); } - /* @VisibleForTesting */ + @VisibleForTesting /* package */ Map getGlobalStyles() { return globalStyles; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndex.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndex.java index 4220f6c5b4..19160c73d4 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndex.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndex.java @@ -15,6 +15,7 @@ */ package com.google.android.exoplayer2.upstream.cache; +import android.support.annotation.VisibleForTesting; import android.util.SparseArray; import com.google.android.exoplayer2.upstream.cache.Cache.CacheException; import com.google.android.exoplayer2.util.Assertions; @@ -336,7 +337,7 @@ import javax.crypto.spec.SecretKeySpec; * than {@link java.lang.Integer#MAX_VALUE} it just returns the next bigger integer. Otherwise it * returns the smallest unused non-negative integer. */ - //@VisibleForTesting + @VisibleForTesting public static int getNewId(SparseArray idToKey) { int size = idToKey.size(); int id = size == 0 ? 0 : (idToKey.keyAt(size - 1) + 1); diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/SphericalSurfaceView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/SphericalSurfaceView.java index bae29a6858..8665852de7 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/SphericalSurfaceView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/SphericalSurfaceView.java @@ -30,6 +30,7 @@ import android.support.annotation.AnyThread; import android.support.annotation.BinderThread; import android.support.annotation.Nullable; import android.support.annotation.UiThread; +import android.support.annotation.VisibleForTesting; import android.util.AttributeSet; import android.view.Display; import android.view.Surface; @@ -230,7 +231,7 @@ public final class SphericalSurfaceView extends GLSurfaceView { * Standard GL Renderer implementation. The notable code is the matrix multiplication in * onDrawFrame and updatePitchMatrix. */ - // @VisibleForTesting + @VisibleForTesting /* package */ class Renderer implements GLSurfaceView.Renderer, TouchTracker.Listener, OrientationListener.Listener { private final SceneRenderer scene; diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/TouchTracker.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/TouchTracker.java index 2da913fc32..08c4779cf7 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/TouchTracker.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/TouchTracker.java @@ -19,6 +19,7 @@ import android.content.Context; import android.graphics.PointF; import android.support.annotation.BinderThread; import android.support.annotation.Nullable; +import android.support.annotation.VisibleForTesting; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; @@ -44,7 +45,7 @@ import android.view.View; * a nicer UI. An even more advanced UI would reproject the user's touch point into 3D and drag the * Mesh as the user moves their finger. However, that requires quaternion interpolation. */ -// @VisibleForTesting +@VisibleForTesting /* package */ class TouchTracker extends GestureDetector.SimpleOnGestureListener implements View.OnTouchListener, OrientationListener.Listener {