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