Use JUnit assert rather than assert keyword

These are turned on by default and can be compiled out entirely for release mode
This commit is contained in:
Christopher Eby 2011-10-04 00:29:21 -05:00
parent fdcf44f36d
commit fc3ce9f551
5 changed files with 21 additions and 15 deletions

View File

@ -51,3 +51,7 @@
-assumenosideeffects class java.lang.String {
public *** format(...);
}
-assumenosideeffects class junit.framework.Assert {
<methods>;
}

View File

@ -53,6 +53,7 @@ import android.widget.ListView;
import android.widget.TabWidget;
import android.widget.TextView;
import android.widget.Toast;
import junit.framework.Assert;
/**
* The library activity where songs to play can be selected from the library.
@ -411,7 +412,7 @@ public class LibraryActivity extends PlaybackActivity implements AdapterView.OnI
if (i == 1) {
// generate the artist limiter (we need to query the artist id)
MediaAdapter.Limiter limiter = mSongAdapter.getLimiter();
assert(limiter.type == MediaUtils.TYPE_ALBUM);
Assert.assertEquals(MediaUtils.TYPE_ALBUM, limiter.type);
ContentResolver resolver = getContentResolver();
Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;

View File

@ -22,9 +22,6 @@
package org.kreed.vanilla;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@ -34,6 +31,9 @@ import android.os.SystemClock;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.KeyEvent;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import junit.framework.Assert;
/**
* Handle a provided MediaButton event and take the appropriate action in
@ -225,7 +225,7 @@ public class MediaButtonHandler {
*/
public void registerMediaButton()
{
assert(mUseControls == 1);
Assert.assertEquals(mUseControls, 1);
if (mRegisterMediaButtonEventReceiver != null) {
try {
mRegisterMediaButtonEventReceiver.invoke(mAudioManager, mButtonReceiver);

View File

@ -30,6 +30,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import junit.framework.Assert;
public class MediaUtils {
/**
@ -253,7 +254,7 @@ public class MediaUtils {
*/
public static void shuffle(Song[] list, int end)
{
assert(end <= list.length && end >= 0);
Assert.assertTrue(end <= list.length && end >= 0);
Random random = getRandom();
for (int i = end; --i != -1; ) {
int j = random.nextInt(i + 1);
@ -457,7 +458,7 @@ public class MediaUtils {
int count = cursor.getCount();
if (count > 0) {
assert(count <= RANDOM_POPULATE_SIZE);
Assert.assertTrue(count <= RANDOM_POPULATE_SIZE);
for (int i = 0; i != count; ++i) {
cursor.moveToNext();

View File

@ -22,6 +22,11 @@
package org.kreed.vanilla;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
@ -31,12 +36,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.ListIterator;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import junit.framework.Assert;
/**
* Represents a series of songs that can be moved through backward or forward.
@ -379,7 +379,7 @@ public final class SongTimeline {
*/
public Song getSong(int delta)
{
assert(delta >= -1 && delta <= 1);
Assert.assertTrue(delta >= -1 && delta <= 1);
ArrayList<Song> timeline = mSongs;
Song song = null;
@ -435,7 +435,7 @@ public final class SongTimeline {
*/
public Song shiftCurrentSong(int delta)
{
assert(delta >= -1 && delta <= 1);
Assert.assertTrue(delta >= -1 && delta <= 1);
synchronized (this) {
int pos = mCurrentPos + delta;