Commit 72dcfd19 by eguven Committed by Oliver Woodman

Automated g4 rollback of changelist 156712385.

*** Reason for rollback ***

This change may silently introduce bugs where both parameters are acceptable in both places. It's decided that the gain isn't worth the risk.

*** Original change description ***

Make the error messages the first parameter in Assertions methods to match JUnit methods

Reverse parameter order creates a slight confusion.

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=156844728
parent 88fddb42
...@@ -200,17 +200,17 @@ public class SampleChooserActivity extends Activity { ...@@ -200,17 +200,17 @@ public class SampleChooserActivity extends Activity {
extension = reader.nextString(); extension = reader.nextString();
break; break;
case "drm_scheme": case "drm_scheme":
Assertions.checkState("Invalid attribute on nested item: drm_scheme", !insidePlaylist); Assertions.checkState(!insidePlaylist, "Invalid attribute on nested item: drm_scheme");
drmUuid = getDrmUuid(reader.nextString()); drmUuid = getDrmUuid(reader.nextString());
break; break;
case "drm_license_url": case "drm_license_url":
Assertions.checkState("Invalid attribute on nested item: drm_license_url", Assertions.checkState(!insidePlaylist,
!insidePlaylist); "Invalid attribute on nested item: drm_license_url");
drmLicenseUrl = reader.nextString(); drmLicenseUrl = reader.nextString();
break; break;
case "drm_key_request_properties": case "drm_key_request_properties":
Assertions.checkState("Invalid attribute on nested item: drm_key_request_properties", Assertions.checkState(!insidePlaylist,
!insidePlaylist); "Invalid attribute on nested item: drm_key_request_properties");
ArrayList<String> drmKeyRequestPropertiesList = new ArrayList<>(); ArrayList<String> drmKeyRequestPropertiesList = new ArrayList<>();
reader.beginObject(); reader.beginObject();
while (reader.hasNext()) { while (reader.hasNext()) {
...@@ -221,12 +221,12 @@ public class SampleChooserActivity extends Activity { ...@@ -221,12 +221,12 @@ public class SampleChooserActivity extends Activity {
drmKeyRequestProperties = drmKeyRequestPropertiesList.toArray(new String[0]); drmKeyRequestProperties = drmKeyRequestPropertiesList.toArray(new String[0]);
break; break;
case "prefer_extension_decoders": case "prefer_extension_decoders":
Assertions.checkState("Invalid attribute on nested item: prefer_extension_decoders", Assertions.checkState(!insidePlaylist,
!insidePlaylist); "Invalid attribute on nested item: prefer_extension_decoders");
preferExtensionDecoders = reader.nextBoolean(); preferExtensionDecoders = reader.nextBoolean();
break; break;
case "playlist": case "playlist":
Assertions.checkState("Invalid nesting of playlists", !insidePlaylist); Assertions.checkState(!insidePlaylist, "Invalid nesting of playlists");
playlistSamples = new ArrayList<>(); playlistSamples = new ArrayList<>();
reader.beginArray(); reader.beginArray();
while (reader.hasNext()) { while (reader.hasNext()) {
......
...@@ -593,7 +593,7 @@ import java.util.List; ...@@ -593,7 +593,7 @@ import java.util.List;
for (int i = 0; i < numberOfEntries; i++) { for (int i = 0; i < numberOfEntries; i++) {
int childStartPosition = stsd.getPosition(); int childStartPosition = stsd.getPosition();
int childAtomSize = stsd.readInt(); int childAtomSize = stsd.readInt();
Assertions.checkArgument("childAtomSize should be positive", childAtomSize > 0); Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
int childAtomType = stsd.readInt(); int childAtomType = stsd.readInt();
if (childAtomType == Atom.TYPE_avc1 || childAtomType == Atom.TYPE_avc3 if (childAtomType == Atom.TYPE_avc1 || childAtomType == Atom.TYPE_avc3
|| childAtomType == Atom.TYPE_encv || childAtomType == Atom.TYPE_mp4v || childAtomType == Atom.TYPE_encv || childAtomType == Atom.TYPE_mp4v
...@@ -693,7 +693,7 @@ import java.util.List; ...@@ -693,7 +693,7 @@ import java.util.List;
// Handle optional terminating four zero bytes in MOV files. // Handle optional terminating four zero bytes in MOV files.
break; break;
} }
Assertions.checkArgument("childAtomSize should be positive", childAtomSize > 0); Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
int childAtomType = parent.readInt(); int childAtomType = parent.readInt();
if (childAtomType == Atom.TYPE_avcC) { if (childAtomType == Atom.TYPE_avcC) {
Assertions.checkState(mimeType == null); Assertions.checkState(mimeType == null);
...@@ -877,7 +877,7 @@ import java.util.List; ...@@ -877,7 +877,7 @@ import java.util.List;
while (childPosition - position < size) { while (childPosition - position < size) {
parent.setPosition(childPosition); parent.setPosition(childPosition);
int childAtomSize = parent.readInt(); int childAtomSize = parent.readInt();
Assertions.checkArgument("childAtomSize should be positive", childAtomSize > 0); Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
int childAtomType = parent.readInt(); int childAtomType = parent.readInt();
if (childAtomType == Atom.TYPE_esds || (isQuickTime && childAtomType == Atom.TYPE_wave)) { if (childAtomType == Atom.TYPE_esds || (isQuickTime && childAtomType == Atom.TYPE_wave)) {
int esdsAtomPosition = childAtomType == Atom.TYPE_esds ? childPosition int esdsAtomPosition = childAtomType == Atom.TYPE_esds ? childPosition
...@@ -936,7 +936,7 @@ import java.util.List; ...@@ -936,7 +936,7 @@ import java.util.List;
while (childAtomPosition - position < size) { while (childAtomPosition - position < size) {
parent.setPosition(childAtomPosition); parent.setPosition(childAtomPosition);
int childAtomSize = parent.readInt(); int childAtomSize = parent.readInt();
Assertions.checkArgument("childAtomSize should be positive", childAtomSize > 0); Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
int childType = parent.readInt(); int childType = parent.readInt();
if (childType == Atom.TYPE_esds) { if (childType == Atom.TYPE_esds) {
return childAtomPosition; return childAtomPosition;
...@@ -1032,7 +1032,7 @@ import java.util.List; ...@@ -1032,7 +1032,7 @@ import java.util.List;
while (childPosition - position < size) { while (childPosition - position < size) {
parent.setPosition(childPosition); parent.setPosition(childPosition);
int childAtomSize = parent.readInt(); int childAtomSize = parent.readInt();
Assertions.checkArgument("childAtomSize should be positive", childAtomSize > 0); Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
int childAtomType = parent.readInt(); int childAtomType = parent.readInt();
if (childAtomType == Atom.TYPE_sinf) { if (childAtomType == Atom.TYPE_sinf) {
Pair<Integer, TrackEncryptionBox> result = parseSinfFromParent(parent, childPosition, Pair<Integer, TrackEncryptionBox> result = parseSinfFromParent(parent, childPosition,
...@@ -1071,8 +1071,8 @@ import java.util.List; ...@@ -1071,8 +1071,8 @@ import java.util.List;
} }
if (isCencScheme) { if (isCencScheme) {
Assertions.checkArgument("frma atom is mandatory", dataFormat != null); Assertions.checkArgument(dataFormat != null, "frma atom is mandatory");
Assertions.checkArgument("schi->tenc atom is mandatory", trackEncryptionBox != null); Assertions.checkArgument(trackEncryptionBox != null, "schi->tenc atom is mandatory");
return Pair.create(dataFormat, trackEncryptionBox); return Pair.create(dataFormat, trackEncryptionBox);
} else { } else {
return null; return null;
...@@ -1157,7 +1157,7 @@ import java.util.List; ...@@ -1157,7 +1157,7 @@ import java.util.List;
length = chunkOffsets.readUnsignedIntToInt(); length = chunkOffsets.readUnsignedIntToInt();
stsc.setPosition(Atom.FULL_HEADER_SIZE); stsc.setPosition(Atom.FULL_HEADER_SIZE);
remainingSamplesPerChunkChanges = stsc.readUnsignedIntToInt(); remainingSamplesPerChunkChanges = stsc.readUnsignedIntToInt();
Assertions.checkState("first_chunk must be 1", stsc.readInt() == 1); Assertions.checkState(stsc.readInt() == 1, "first_chunk must be 1");
index = C.INDEX_UNSET; index = C.INDEX_UNSET;
} }
......
...@@ -388,7 +388,7 @@ public final class FragmentedMp4Extractor implements Extractor { ...@@ -388,7 +388,7 @@ public final class FragmentedMp4Extractor implements Extractor {
} }
private void onMoovContainerAtomRead(ContainerAtom moov) throws ParserException { private void onMoovContainerAtomRead(ContainerAtom moov) throws ParserException {
Assertions.checkState("Unexpected moov box.", sideloadedTrack == null); Assertions.checkState(sideloadedTrack == null, "Unexpected moov box.");
DrmInitData drmInitData = getDrmInitDataFromAtoms(moov.leafChildren); DrmInitData drmInitData = getDrmInitDataFromAtoms(moov.leafChildren);
......
...@@ -48,9 +48,9 @@ import java.util.List; ...@@ -48,9 +48,9 @@ import java.util.List;
TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT); TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT);
Format channelFormat = closedCaptionFormats.get(i); Format channelFormat = closedCaptionFormats.get(i);
String channelMimeType = channelFormat.sampleMimeType; String channelMimeType = channelFormat.sampleMimeType;
Assertions.checkArgument("Invalid closed caption mime type provided: " + channelMimeType, Assertions.checkArgument(MimeTypes.APPLICATION_CEA608.equals(channelMimeType)
MimeTypes.APPLICATION_CEA608.equals(channelMimeType) || MimeTypes.APPLICATION_CEA708.equals(channelMimeType),
|| MimeTypes.APPLICATION_CEA708.equals(channelMimeType)); "Invalid closed caption mime type provided: " + channelMimeType);
output.format(Format.createTextSampleFormat(idGenerator.getFormatId(), channelMimeType, null, output.format(Format.createTextSampleFormat(idGenerator.getFormatId(), channelMimeType, null,
Format.NO_VALUE, channelFormat.selectionFlags, channelFormat.language, Format.NO_VALUE, channelFormat.selectionFlags, channelFormat.language,
channelFormat.accessibilityChannel, null)); channelFormat.accessibilityChannel, null));
......
...@@ -170,8 +170,8 @@ public final class ConcatenatingMediaSource implements MediaSource { ...@@ -170,8 +170,8 @@ public final class ConcatenatingMediaSource implements MediaSource {
for (int i = 0; i < timelines.length; i++) { for (int i = 0; i < timelines.length; i++) {
Timeline timeline = timelines[i]; Timeline timeline = timelines[i];
periodCount += timeline.getPeriodCount(); periodCount += timeline.getPeriodCount();
Assertions.checkState("ConcatenatingMediaSource children contain too many periods", Assertions.checkState(periodCount <= Integer.MAX_VALUE,
periodCount <= Integer.MAX_VALUE); "ConcatenatingMediaSource children contain too many periods");
sourcePeriodOffsets[i] = (int) periodCount; sourcePeriodOffsets[i] = (int) periodCount;
windowCount += timeline.getWindowCount(); windowCount += timeline.getWindowCount();
sourceWindowOffsets[i] = windowCount; sourceWindowOffsets[i] = windowCount;
......
...@@ -102,8 +102,8 @@ public final class LoopingMediaSource implements MediaSource { ...@@ -102,8 +102,8 @@ public final class LoopingMediaSource implements MediaSource {
childPeriodCount = childTimeline.getPeriodCount(); childPeriodCount = childTimeline.getPeriodCount();
childWindowCount = childTimeline.getWindowCount(); childWindowCount = childTimeline.getWindowCount();
this.loopCount = loopCount; this.loopCount = loopCount;
Assertions.checkState("LoopingMediaSource contains too many periods", Assertions.checkState(loopCount <= Integer.MAX_VALUE / childPeriodCount,
loopCount <= Integer.MAX_VALUE / childPeriodCount); "LoopingMediaSource contains too many periods");
} }
@Override @Override
......
...@@ -41,12 +41,12 @@ public final class Assertions { ...@@ -41,12 +41,12 @@ public final class Assertions {
/** /**
* Throws {@link IllegalArgumentException} if {@code expression} evaluates to false. * Throws {@link IllegalArgumentException} if {@code expression} evaluates to false.
* *
* @param expression The expression to evaluate.
* @param errorMessage The exception message if an exception is thrown. The message is converted * @param errorMessage The exception message if an exception is thrown. The message is converted
* to a {@link String} using {@link String#valueOf(Object)}. * to a {@link String} using {@link String#valueOf(Object)}.
* @param expression The expression to evaluate.
* @throws IllegalArgumentException If {@code expression} is false. * @throws IllegalArgumentException If {@code expression} is false.
*/ */
public static void checkArgument(Object errorMessage, boolean expression) { public static void checkArgument(boolean expression, Object errorMessage) {
if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && !expression) { if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && !expression) {
throw new IllegalArgumentException(String.valueOf(errorMessage)); throw new IllegalArgumentException(String.valueOf(errorMessage));
} }
...@@ -83,12 +83,12 @@ public final class Assertions { ...@@ -83,12 +83,12 @@ public final class Assertions {
/** /**
* Throws {@link IllegalStateException} if {@code expression} evaluates to false. * Throws {@link IllegalStateException} if {@code expression} evaluates to false.
* *
* @param expression The expression to evaluate.
* @param errorMessage The exception message if an exception is thrown. The message is converted * @param errorMessage The exception message if an exception is thrown. The message is converted
* to a {@link String} using {@link String#valueOf(Object)}. * to a {@link String} using {@link String#valueOf(Object)}.
* @param expression The expression to evaluate.
* @throws IllegalStateException If {@code expression} is false. * @throws IllegalStateException If {@code expression} is false.
*/ */
public static void checkState(Object errorMessage, boolean expression) { public static void checkState(boolean expression, Object errorMessage) {
if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && !expression) { if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && !expression) {
throw new IllegalStateException(String.valueOf(errorMessage)); throw new IllegalStateException(String.valueOf(errorMessage));
} }
...@@ -113,13 +113,13 @@ public final class Assertions { ...@@ -113,13 +113,13 @@ public final class Assertions {
* Throws {@link NullPointerException} if {@code reference} is null. * Throws {@link NullPointerException} if {@code reference} is null.
* *
* @param <T> The type of the reference. * @param <T> The type of the reference.
* @param reference The reference.
* @param errorMessage The exception message to use if the check fails. The message is converted * @param errorMessage The exception message to use if the check fails. The message is converted
* to a string using {@link String#valueOf(Object)}. * to a string using {@link String#valueOf(Object)}.
* @param reference The reference.
* @return The non-null reference that was validated. * @return The non-null reference that was validated.
* @throws NullPointerException If {@code reference} is null. * @throws NullPointerException If {@code reference} is null.
*/ */
public static <T> T checkNotNull(Object errorMessage, T reference) { public static <T> T checkNotNull(T reference, Object errorMessage) {
if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && reference == null) { if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && reference == null) {
throw new NullPointerException(String.valueOf(errorMessage)); throw new NullPointerException(String.valueOf(errorMessage));
} }
...@@ -143,13 +143,13 @@ public final class Assertions { ...@@ -143,13 +143,13 @@ public final class Assertions {
/** /**
* Throws {@link IllegalArgumentException} if {@code string} is null or zero length. * Throws {@link IllegalArgumentException} if {@code string} is null or zero length.
* *
* @param string The string to check.
* @param errorMessage The exception message to use if the check fails. The message is converted * @param errorMessage The exception message to use if the check fails. The message is converted
* to a string using {@link String#valueOf(Object)}. * to a string using {@link String#valueOf(Object)}.
* @param string The string to check.
* @return The non-null, non-empty string that was validated. * @return The non-null, non-empty string that was validated.
* @throws IllegalArgumentException If {@code string} is null or 0-length. * @throws IllegalArgumentException If {@code string} is null or 0-length.
*/ */
public static String checkNotEmpty(Object errorMessage, String string) { public static String checkNotEmpty(String string, Object errorMessage) {
if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && TextUtils.isEmpty(string)) { if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && TextUtils.isEmpty(string)) {
throw new IllegalArgumentException(String.valueOf(errorMessage)); throw new IllegalArgumentException(String.valueOf(errorMessage));
} }
......
...@@ -36,7 +36,7 @@ public final class LibraryLoader { ...@@ -36,7 +36,7 @@ public final class LibraryLoader {
* {@link #isAvailable()}. * {@link #isAvailable()}.
*/ */
public synchronized void setLibraries(String... libraries) { public synchronized void setLibraries(String... libraries) {
Assertions.checkState("Cannot set libraries after loading", !loadAttempted); Assertions.checkState(!loadAttempted, "Cannot set libraries after loading");
nativeLibraries = libraries; nativeLibraries = libraries;
} }
......
...@@ -226,11 +226,11 @@ public final class DummySurface extends Surface { ...@@ -226,11 +226,11 @@ public final class DummySurface extends Surface {
private void initInternal(boolean secure) { private void initInternal(boolean secure) {
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
Assertions.checkState("eglGetDisplay failed", display != null); Assertions.checkState(display != null, "eglGetDisplay failed");
int[] version = new int[2]; int[] version = new int[2];
boolean eglInitialized = eglInitialize(display, version, 0, version, 1); boolean eglInitialized = eglInitialize(display, version, 0, version, 1);
Assertions.checkState("eglInitialize failed", eglInitialized); Assertions.checkState(eglInitialized, "eglInitialize failed");
int[] eglAttributes = new int[] { int[] eglAttributes = new int[] {
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
...@@ -247,8 +247,8 @@ public final class DummySurface extends Surface { ...@@ -247,8 +247,8 @@ public final class DummySurface extends Surface {
int[] numConfigs = new int[1]; int[] numConfigs = new int[1];
boolean eglChooseConfigSuccess = eglChooseConfig(display, eglAttributes, 0, configs, 0, 1, boolean eglChooseConfigSuccess = eglChooseConfig(display, eglAttributes, 0, configs, 0, 1,
numConfigs, 0); numConfigs, 0);
Assertions.checkState("eglChooseConfig failed", Assertions.checkState(eglChooseConfigSuccess && numConfigs[0] > 0 && configs[0] != null,
eglChooseConfigSuccess && numConfigs[0] > 0 && configs[0] != null); "eglChooseConfig failed");
EGLConfig config = configs[0]; EGLConfig config = configs[0];
int[] glAttributes; int[] glAttributes;
...@@ -264,7 +264,7 @@ public final class DummySurface extends Surface { ...@@ -264,7 +264,7 @@ public final class DummySurface extends Surface {
} }
EGLContext context = eglCreateContext(display, config, android.opengl.EGL14.EGL_NO_CONTEXT, EGLContext context = eglCreateContext(display, config, android.opengl.EGL14.EGL_NO_CONTEXT,
glAttributes, 0); glAttributes, 0);
Assertions.checkState("eglCreateContext failed", context != null); Assertions.checkState(context != null, "eglCreateContext failed");
int[] pbufferAttributes; int[] pbufferAttributes;
if (secure) { if (secure) {
...@@ -280,10 +280,10 @@ public final class DummySurface extends Surface { ...@@ -280,10 +280,10 @@ public final class DummySurface extends Surface {
EGL_NONE}; EGL_NONE};
} }
EGLSurface pbuffer = eglCreatePbufferSurface(display, config, pbufferAttributes, 0); EGLSurface pbuffer = eglCreatePbufferSurface(display, config, pbufferAttributes, 0);
Assertions.checkState("eglCreatePbufferSurface failed", pbuffer != null); Assertions.checkState(pbuffer != null, "eglCreatePbufferSurface failed");
boolean eglMadeCurrent = eglMakeCurrent(display, pbuffer, pbuffer, context); boolean eglMadeCurrent = eglMakeCurrent(display, pbuffer, pbuffer, context);
Assertions.checkState("eglMakeCurrent failed", eglMadeCurrent); Assertions.checkState(eglMadeCurrent, "eglMakeCurrent failed");
glGenTextures(1, textureIdHolder, 0); glGenTextures(1, textureIdHolder, 0);
surfaceTexture = new SurfaceTexture(textureIdHolder[0]); surfaceTexture = new SurfaceTexture(textureIdHolder[0]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment