aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/src/com/android/tv/data/ChannelDataManagerTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/src/com/android/tv/data/ChannelDataManagerTest.java')
-rw-r--r--tests/unit/src/com/android/tv/data/ChannelDataManagerTest.java325
1 files changed, 177 insertions, 148 deletions
diff --git a/tests/unit/src/com/android/tv/data/ChannelDataManagerTest.java b/tests/unit/src/com/android/tv/data/ChannelDataManagerTest.java
index 7a4a4982..96c1f7a1 100644
--- a/tests/unit/src/com/android/tv/data/ChannelDataManagerTest.java
+++ b/tests/unit/src/com/android/tv/data/ChannelDataManagerTest.java
@@ -18,9 +18,8 @@ package com.android.tv.data;
import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static android.support.test.InstrumentationRegistry.getTargetContext;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
import android.content.ContentProvider;
import android.content.ContentUris;
@@ -31,7 +30,9 @@ import android.database.Cursor;
import android.media.tv.TvContract;
import android.media.tv.TvContract.Channels;
import android.net.Uri;
+import android.os.AsyncTask;
import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
import android.test.MoreAsserts;
import android.test.mock.MockContentProvider;
import android.test.mock.MockContentResolver;
@@ -39,30 +40,30 @@ import android.test.mock.MockCursor;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
-
-import com.android.tv.testing.ChannelInfo;
-import com.android.tv.testing.Constants;
+import com.android.tv.data.api.Channel;
+import com.android.tv.testing.constants.Constants;
+import com.android.tv.testing.data.ChannelInfo;
import com.android.tv.util.TvInputManagerHelper;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Matchers;
-import org.mockito.Mockito;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mockito;
/**
* Test for {@link ChannelDataManager}
*
- * A test method may include tests for multiple methods to minimize the DB access.
- * Note that all the methods of {@link ChannelDataManager} should be called from the UI thread.
+ * <p>A test method may include tests for multiple methods to minimize the DB access. Note that all
+ * the methods of {@link ChannelDataManager} should be called from the UI thread.
*/
@SmallTest
+@RunWith(AndroidJUnit4.class)
public class ChannelDataManagerTest {
private static final boolean DEBUG = false;
private static final String TAG = "ChannelDataManagerTest";
@@ -80,73 +81,89 @@ public class ChannelDataManagerTest {
@Before
public void setUp() {
- assertTrue("More than 2 channels to test", Constants.UNIT_TEST_CHANNEL_COUNT > 2);
+ assertWithMessage("More than 2 channels to test")
+ .that(Constants.UNIT_TEST_CHANNEL_COUNT > 2)
+ .isTrue();
mContentProvider = new FakeContentProvider(getTargetContext());
mContentResolver = new FakeContentResolver();
mContentResolver.addProvider(TvContract.AUTHORITY, mContentProvider);
mListener = new TestChannelDataManagerListener();
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- TvInputManagerHelper mockHelper = Mockito.mock(TvInputManagerHelper.class);
- Mockito.when(mockHelper.hasTvInputInfo(Matchers.anyString())).thenReturn(true);
- mChannelDataManager = new ChannelDataManager(getTargetContext(), mockHelper,
- mContentResolver);
- mChannelDataManager.addListener(mListener);
- }
- });
+ getInstrumentation()
+ .runOnMainSync(
+ new Runnable() {
+ @Override
+ public void run() {
+ TvInputManagerHelper mockHelper =
+ Mockito.mock(TvInputManagerHelper.class);
+ Mockito.when(mockHelper.hasTvInputInfo(Matchers.anyString()))
+ .thenReturn(true);
+ mChannelDataManager =
+ new ChannelDataManager(
+ getTargetContext(),
+ mockHelper,
+ AsyncTask.SERIAL_EXECUTOR,
+ mContentResolver);
+ mChannelDataManager.addListener(mListener);
+ }
+ });
}
@After
public void tearDown() {
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- mChannelDataManager.stop();
- }
- });
+ getInstrumentation()
+ .runOnMainSync(
+ new Runnable() {
+ @Override
+ public void run() {
+ mChannelDataManager.stop();
+ }
+ });
}
private void startAndWaitForComplete() throws InterruptedException {
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- mChannelDataManager.start();
- }
- });
- assertTrue(mListener.loadFinishedLatch.await(WAIT_TIME_OUT_MS, TimeUnit.MILLISECONDS));
+ getInstrumentation()
+ .runOnMainSync(
+ new Runnable() {
+ @Override
+ public void run() {
+ mChannelDataManager.start();
+ }
+ });
+ assertThat(mListener.loadFinishedLatch.await(WAIT_TIME_OUT_MS, TimeUnit.MILLISECONDS))
+ .isTrue();
}
private void restart() throws InterruptedException {
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- mChannelDataManager.stop();
- mListener.reset();
- }
- });
+ getInstrumentation()
+ .runOnMainSync(
+ new Runnable() {
+ @Override
+ public void run() {
+ mChannelDataManager.stop();
+ mListener.reset();
+ }
+ });
startAndWaitForComplete();
}
@Test
public void testIsDbLoadFinished() throws InterruptedException {
startAndWaitForComplete();
- assertTrue(mChannelDataManager.isDbLoadFinished());
+ assertThat(mChannelDataManager.isDbLoadFinished()).isTrue();
}
/**
- * Test for following methods
- * - {@link ChannelDataManager#getChannelCount}
- * - {@link ChannelDataManager#getChannelList}
- * - {@link ChannelDataManager#getChannel}
+ * Test for following methods - {@link ChannelDataManager#getChannelCount} - {@link
+ * ChannelDataManager#getChannelList} - {@link ChannelDataManager#getChannel}
*/
@Test
public void testGetChannels() throws InterruptedException {
startAndWaitForComplete();
// Test {@link ChannelDataManager#getChannelCount}
- assertEquals(Constants.UNIT_TEST_CHANNEL_COUNT, mChannelDataManager.getChannelCount());
+ assertThat(mChannelDataManager.getChannelCount())
+ .isEqualTo(Constants.UNIT_TEST_CHANNEL_COUNT);
// Test {@link ChannelDataManager#getChannelList}
List<ChannelInfo> channelInfoList = new ArrayList<>();
@@ -157,36 +174,32 @@ public class ChannelDataManagerTest {
for (Channel channel : channelList) {
boolean found = false;
for (ChannelInfo channelInfo : channelInfoList) {
- if (TextUtils.equals(channelInfo.name, channel.getDisplayName())
- && TextUtils.equals(channelInfo.name, channel.getDisplayName())) {
+ if (TextUtils.equals(channelInfo.name, channel.getDisplayName())) {
found = true;
channelInfoList.remove(channelInfo);
break;
}
}
- assertTrue("Cannot find (" + channel + ")", found);
+ assertWithMessage("Cannot find (" + channel + ")").that(found).isTrue();
}
// Test {@link ChannelDataManager#getChannelIndex()}
for (Channel channel : channelList) {
- assertEquals(channel, mChannelDataManager.getChannel(channel.getId()));
+ assertThat(mChannelDataManager.getChannel(channel.getId())).isEqualTo(channel);
}
}
- /**
- * Test for {@link ChannelDataManager#getChannelCount} when no channel is available.
- */
+ /** Test for {@link ChannelDataManager#getChannelCount} when no channel is available. */
@Test
public void testGetChannels_noChannels() throws InterruptedException {
mContentProvider.clear();
startAndWaitForComplete();
- assertEquals(0, mChannelDataManager.getChannelCount());
+ assertThat(mChannelDataManager.getChannelCount()).isEqualTo(0);
}
/**
- * Test for following methods and channel listener with notifying change.
- * - {@link ChannelDataManager#updateBrowsable}
- * - {@link ChannelDataManager#applyUpdatedValuesToDb}
+ * Test for following methods and channel listener with notifying change. - {@link
+ * ChannelDataManager#updateBrowsable} - {@link ChannelDataManager#applyUpdatedValuesToDb}
*/
@Test
public void testBrowsable() throws InterruptedException {
@@ -197,9 +210,9 @@ public class ChannelDataManagerTest {
List<Channel> browsableChannelList = mChannelDataManager.getBrowsableChannelList();
for (Channel browsableChannel : browsableChannelList) {
boolean found = channelList.remove(browsableChannel);
- assertTrue("Cannot find (" + browsableChannel + ")", found);
+ assertWithMessage("Cannot find (" + browsableChannel + ")").that(found).isTrue();
}
- assertEquals(0, channelList.size());
+ assertThat(channelList).isEmpty();
// Prepare for next tests.
channelList = mChannelDataManager.getChannelList();
@@ -210,8 +223,8 @@ public class ChannelDataManagerTest {
// Test {@link ChannelDataManager#updateBrowsable} & notification.
mChannelDataManager.updateBrowsable(channel1.getId(), false, false);
- assertTrue(mListener.channelBrowsableChangedCalled);
- assertFalse(mChannelDataManager.getBrowsableChannelList().contains(channel1));
+ assertThat(mListener.channelBrowsableChangedCalled).isTrue();
+ assertThat(mChannelDataManager.getBrowsableChannelList()).doesNotContain(channel1);
MoreAsserts.assertContentsInAnyOrder(channelListener.updatedChannels, channel1);
channelListener.reset();
@@ -221,14 +234,13 @@ public class ChannelDataManagerTest {
mChannelDataManager.applyUpdatedValuesToDb();
restart();
browsableChannelList = mChannelDataManager.getBrowsableChannelList();
- assertEquals(Constants.UNIT_TEST_CHANNEL_COUNT - 1, browsableChannelList.size());
- assertFalse(browsableChannelList.contains(channel1));
+ assertThat(browsableChannelList).hasSize(Constants.UNIT_TEST_CHANNEL_COUNT - 1);
+ assertThat(browsableChannelList).doesNotContain(channel1);
}
/**
- * Test for following methods and channel listener without notifying change.
- * - {@link ChannelDataManager#updateBrowsable}
- * - {@link ChannelDataManager#applyUpdatedValuesToDb}
+ * Test for following methods and channel listener without notifying change. - {@link
+ * ChannelDataManager#updateBrowsable} - {@link ChannelDataManager#applyUpdatedValuesToDb}
*/
@Test
public void testBrowsable_skipNotification() throws InterruptedException {
@@ -247,10 +259,10 @@ public class ChannelDataManagerTest {
mChannelDataManager.updateBrowsable(channel1.getId(), false, true);
mChannelDataManager.updateBrowsable(channel2.getId(), false, true);
mChannelDataManager.updateBrowsable(channel1.getId(), true, true);
- assertFalse(mListener.channelBrowsableChangedCalled);
+ assertThat(mListener.channelBrowsableChangedCalled).isFalse();
List<Channel> browsableChannelList = mChannelDataManager.getBrowsableChannelList();
- assertTrue(browsableChannelList.contains(channel1));
- assertFalse(browsableChannelList.contains(channel2));
+ assertThat(browsableChannelList).contains(channel1);
+ assertThat(browsableChannelList).doesNotContain(channel2);
// Test {@link ChannelDataManager#applyUpdatedValuesToDb}
// Disable the update notification to avoid the unwanted call of "onLoadFinished".
@@ -258,14 +270,13 @@ public class ChannelDataManagerTest {
mChannelDataManager.applyUpdatedValuesToDb();
restart();
browsableChannelList = mChannelDataManager.getBrowsableChannelList();
- assertEquals(Constants.UNIT_TEST_CHANNEL_COUNT - 1, browsableChannelList.size());
- assertFalse(browsableChannelList.contains(channel2));
+ assertThat(browsableChannelList).hasSize(Constants.UNIT_TEST_CHANNEL_COUNT - 1);
+ assertThat(browsableChannelList).doesNotContain(channel2);
}
/**
- * Test for following methods and channel listener.
- * - {@link ChannelDataManager#updateLocked}
- * - {@link ChannelDataManager#applyUpdatedValuesToDb}
+ * Test for following methods and channel listener. - {@link ChannelDataManager#updateLocked} -
+ * {@link ChannelDataManager#applyUpdatedValuesToDb}
*/
@Test
public void testLocked() throws InterruptedException {
@@ -274,7 +285,7 @@ public class ChannelDataManagerTest {
// Test if all channels aren't locked at the first time.
List<Channel> channelList = mChannelDataManager.getChannelList();
for (Channel channel : channelList) {
- assertFalse(channel + " is locked", channel.isLocked());
+ assertWithMessage(channel + " is locked").that(channel.isLocked()).isFalse();
}
// Prepare for next tests.
@@ -282,22 +293,20 @@ public class ChannelDataManagerTest {
// Test {@link ChannelDataManager#updateLocked}
mChannelDataManager.updateLocked(channel.getId(), true);
- assertTrue(mChannelDataManager.getChannel(channel.getId()).isLocked());
+ assertThat(mChannelDataManager.getChannel(channel.getId()).isLocked()).isTrue();
// Test {@link ChannelDataManager#applyUpdatedValuesToDb}.
// Disable the update notification to avoid the unwanted call of "onLoadFinished".
mContentResolver.mNotifyDisabled = true;
mChannelDataManager.applyUpdatedValuesToDb();
restart();
- assertTrue(mChannelDataManager.getChannel(channel.getId()).isLocked());
+ assertThat(mChannelDataManager.getChannel(channel.getId()).isLocked()).isTrue();
// Cleanup
mChannelDataManager.updateLocked(channel.getId(), false);
}
- /**
- * Test ChannelDataManager when channels in TvContract are updated, removed, or added.
- */
+ /** Test ChannelDataManager when channels in TvContract are updated, removed, or added. */
@Test
public void testChannelListChanged() throws InterruptedException {
startAndWaitForComplete();
@@ -308,9 +317,10 @@ public class ChannelDataManagerTest {
ChannelInfo testChannelInfo = ChannelInfo.create(getTargetContext(), (int) testChannelId);
testChannelId = Constants.UNIT_TEST_CHANNEL_COUNT + 1;
mContentProvider.simulateInsert(testChannelInfo);
- assertTrue(
- mListener.channelListUpdatedLatch.await(WAIT_TIME_OUT_MS, TimeUnit.MILLISECONDS));
- assertEquals(Constants.UNIT_TEST_CHANNEL_COUNT + 1, mChannelDataManager.getChannelCount());
+ assertThat(mListener.channelListUpdatedLatch.await(WAIT_TIME_OUT_MS, TimeUnit.MILLISECONDS))
+ .isTrue();
+ assertThat(mChannelDataManager.getChannelCount())
+ .isEqualTo(Constants.UNIT_TEST_CHANNEL_COUNT + 1);
// Test channel update
mListener.reset();
@@ -319,39 +329,45 @@ public class ChannelDataManagerTest {
mChannelDataManager.addChannelListener(testChannelId, channelListener);
String newName = testChannelInfo.name + "_test";
mContentProvider.simulateUpdate(testChannelId, newName);
- assertTrue(
- mListener.channelListUpdatedLatch.await(WAIT_TIME_OUT_MS, TimeUnit.MILLISECONDS));
- assertTrue(
- channelListener.channelChangedLatch.await(WAIT_TIME_OUT_MS, TimeUnit.MILLISECONDS));
- assertEquals(0, channelListener.removedChannels.size());
- assertEquals(1, channelListener.updatedChannels.size());
+ assertThat(mListener.channelListUpdatedLatch.await(WAIT_TIME_OUT_MS, TimeUnit.MILLISECONDS))
+ .isTrue();
+ assertThat(
+ channelListener.channelChangedLatch.await(
+ WAIT_TIME_OUT_MS, TimeUnit.MILLISECONDS))
+ .isTrue();
+ assertThat(channelListener.removedChannels).isEmpty();
+ assertThat(channelListener.updatedChannels).hasSize(1);
Channel updatedChannel = channelListener.updatedChannels.get(0);
- assertEquals(testChannelId, updatedChannel.getId());
- assertEquals(testChannelInfo.number, updatedChannel.getDisplayNumber());
- assertEquals(newName, updatedChannel.getDisplayName());
- assertEquals(Constants.UNIT_TEST_CHANNEL_COUNT + 1,
- mChannelDataManager.getChannelCount());
+ assertThat(updatedChannel.getId()).isEqualTo(testChannelId);
+ assertThat(updatedChannel.getDisplayNumber()).isEqualTo(testChannelInfo.number);
+ assertThat(updatedChannel.getDisplayName()).isEqualTo(newName);
+ assertThat(mChannelDataManager.getChannelCount())
+ .isEqualTo(Constants.UNIT_TEST_CHANNEL_COUNT + 1);
// Test channel remove.
mListener.reset();
channelListener.reset();
mContentProvider.simulateDelete(testChannelId);
- assertTrue(
- mListener.channelListUpdatedLatch.await(WAIT_TIME_OUT_MS, TimeUnit.MILLISECONDS));
- assertTrue(
- channelListener.channelChangedLatch.await(WAIT_TIME_OUT_MS, TimeUnit.MILLISECONDS));
- assertEquals(1, channelListener.removedChannels.size());
- assertEquals(0, channelListener.updatedChannels.size());
+ assertThat(mListener.channelListUpdatedLatch.await(WAIT_TIME_OUT_MS, TimeUnit.MILLISECONDS))
+ .isTrue();
+ assertThat(
+ channelListener.channelChangedLatch.await(
+ WAIT_TIME_OUT_MS, TimeUnit.MILLISECONDS))
+ .isTrue();
+ assertThat(channelListener.removedChannels).hasSize(1);
+ assertThat(channelListener.updatedChannels).isEmpty();
Channel removedChannel = channelListener.removedChannels.get(0);
- assertEquals(newName, removedChannel.getDisplayName());
- assertEquals(testChannelInfo.number, removedChannel.getDisplayNumber());
- assertEquals(Constants.UNIT_TEST_CHANNEL_COUNT, mChannelDataManager.getChannelCount());
+ assertThat(removedChannel.getDisplayName()).isEqualTo(newName);
+ assertThat(removedChannel.getDisplayNumber()).isEqualTo(testChannelInfo.number);
+ assertThat(mChannelDataManager.getChannelCount())
+ .isEqualTo(Constants.UNIT_TEST_CHANNEL_COUNT);
}
- private class ChannelInfoWrapper {
+ private static class ChannelInfoWrapper {
public ChannelInfo channelInfo;
public boolean browsable;
public boolean locked;
+
public ChannelInfoWrapper(ChannelInfo channelInfo) {
this.channelInfo = channelInfo;
browsable = true;
@@ -366,8 +382,14 @@ public class ChannelDataManagerTest {
public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) {
super.notifyChange(uri, observer, syncToNetwork);
if (DEBUG) {
- Log.d(TAG, "onChanged(uri=" + uri + ", observer=" + observer + ") - Notification "
- + (mNotifyDisabled ? "disabled" : "enabled"));
+ Log.d(
+ TAG,
+ "onChanged(uri="
+ + uri
+ + ", observer="
+ + observer
+ + ") - Notification "
+ + (mNotifyDisabled ? "disabled" : "enabled"));
}
if (mNotifyDisabled) {
return;
@@ -390,19 +412,23 @@ public class ChannelDataManagerTest {
public FakeContentProvider(Context context) {
super(context);
for (int i = 1; i <= Constants.UNIT_TEST_CHANNEL_COUNT; i++) {
- mChannelInfoList.put(i,
- new ChannelInfoWrapper(ChannelInfo.create(getTargetContext(), i)));
+ mChannelInfoList.put(
+ i, new ChannelInfoWrapper(ChannelInfo.create(getTargetContext(), i)));
}
}
/**
- * Implementation of {@link ContentProvider#query}.
- * This assumes that {@link ChannelDataManager} queries channels
- * with empty {@code selection}. (i.e. channels are always queries for all)
+ * Implementation of {@link ContentProvider#query}. This assumes that {@link
+ * ChannelDataManager} queries channels with empty {@code selection}. (i.e. channels are
+ * always queries for all)
*/
@Override
- public Cursor query(Uri uri, String[] projection, String selection, String[]
- selectionArgs, String sortOrder) {
+ public Cursor query(
+ Uri uri,
+ String[] projection,
+ String selection,
+ String[] selectionArgs,
+ String sortOrder) {
if (DEBUG) {
Log.d(TAG, "dump query");
Log.d(TAG, " uri=" + uri);
@@ -414,9 +440,8 @@ public class ChannelDataManagerTest {
}
/**
- * Implementation of {@link ContentProvider#update}.
- * This assumes that {@link ChannelDataManager} update channels
- * only for changing browsable and locked.
+ * Implementation of {@link ContentProvider#update}. This assumes that {@link
+ * ChannelDataManager} update channels only for changing browsable and locked.
*/
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
@@ -434,8 +459,9 @@ public class ChannelDataManagerTest {
}
} else {
// See {@link Utils#buildSelectionForIds} for the syntax.
- String selectionForId = selection.substring(
- selection.indexOf("(") + 1, selection.lastIndexOf(")"));
+ String selectionForId =
+ selection.substring(
+ selection.indexOf("(") + 1, selection.lastIndexOf(")"));
String[] ids = selectionForId.split(", ");
if (ids != null) {
for (String id : ids) {
@@ -476,27 +502,25 @@ public class ChannelDataManagerTest {
}
/**
- * Simulates channel data insert.
- * This assigns original network ID (the same with channel number) to channel ID.
+ * Simulates channel data insert. This assigns original network ID (the same with channel
+ * number) to channel ID.
*/
public void simulateInsert(ChannelInfo testChannelInfo) {
long channelId = testChannelInfo.originalNetworkId;
- mChannelInfoList.put((int) channelId, new ChannelInfoWrapper(
- ChannelInfo.create(getTargetContext(), (int) channelId)));
+ mChannelInfoList.put(
+ (int) channelId,
+ new ChannelInfoWrapper(
+ ChannelInfo.create(getTargetContext(), (int) channelId)));
mContentResolver.notifyChange(TvContract.buildChannelUri(channelId), null);
}
- /**
- * Simulates channel data delete.
- */
+ /** Simulates channel data delete. */
public void simulateDelete(long channelId) {
mChannelInfoList.remove((int) channelId);
mContentResolver.notifyChange(TvContract.buildChannelUri(channelId), null);
}
- /**
- * Simulates channel data update.
- */
+ /** Simulates channel data update. */
public void simulateUpdate(long channelId, String newName) {
ChannelInfoWrapper channel = mChannelInfoList.get((int) channelId);
ChannelInfo.Builder builder = new ChannelInfo.Builder(channel.channelInfo);
@@ -506,8 +530,9 @@ public class ChannelDataManagerTest {
}
private void assertChannelUri(Uri uri) {
- assertTrue("Uri(" + uri + ") isn't channel uri",
- uri.toString().startsWith(Channels.CONTENT_URI.toString()));
+ assertWithMessage("Uri(" + uri + ") isn't channel uri")
+ .that(uri.toString().startsWith(Channels.CONTENT_URI.toString()))
+ .isTrue();
}
public void clear() {
@@ -528,20 +553,21 @@ public class ChannelDataManagerTest {
}
private class FakeCursor extends MockCursor {
- private final String[] ALL_COLUMNS = {
- Channels._ID,
- Channels.COLUMN_DISPLAY_NAME,
- Channels.COLUMN_DISPLAY_NUMBER,
- Channels.COLUMN_INPUT_ID,
- Channels.COLUMN_VIDEO_FORMAT,
- Channels.COLUMN_ORIGINAL_NETWORK_ID,
- COLUMN_BROWSABLE,
- COLUMN_LOCKED};
+ private final String[] allColumns = {
+ Channels._ID,
+ Channels.COLUMN_DISPLAY_NAME,
+ Channels.COLUMN_DISPLAY_NUMBER,
+ Channels.COLUMN_INPUT_ID,
+ Channels.COLUMN_VIDEO_FORMAT,
+ Channels.COLUMN_ORIGINAL_NETWORK_ID,
+ COLUMN_BROWSABLE,
+ COLUMN_LOCKED
+ };
private final String[] mColumns;
private int mPosition;
public FakeCursor(String[] columns) {
- mColumns = (columns == null) ? ALL_COLUMNS : columns;
+ mColumns = (columns == null) ? allColumns : columns;
mPosition = -1;
}
@@ -566,6 +592,7 @@ public class ChannelDataManagerTest {
switch (columnName) {
case Channels._ID:
return mContentProvider.keyAt(mPosition);
+ default: // fall out
}
if (DEBUG) {
Log.d(TAG, "Column (" + columnName + ") is ignored in getLong()");
@@ -586,6 +613,7 @@ public class ChannelDataManagerTest {
return DUMMY_INPUT_ID;
case Channels.COLUMN_VIDEO_FORMAT:
return channel.channelInfo.getVideoFormat();
+ default: // fall out
}
if (DEBUG) {
Log.d(TAG, "Column (" + columnName + ") is ignored in getString()");
@@ -604,6 +632,7 @@ public class ChannelDataManagerTest {
return channel.browsable ? 1 : 0;
case COLUMN_LOCKED:
return channel.locked ? 1 : 0;
+ default: // fall out
}
if (DEBUG) {
Log.d(TAG, "Column (" + columnName + ") is ignored in getInt()");
@@ -627,7 +656,7 @@ public class ChannelDataManagerTest {
}
}
- private class TestChannelDataManagerListener implements ChannelDataManager.Listener {
+ private static class TestChannelDataManagerListener implements ChannelDataManager.Listener {
public CountDownLatch loadFinishedLatch = new CountDownLatch(1);
public CountDownLatch channelListUpdatedLatch = new CountDownLatch(1);
public boolean channelBrowsableChangedCalled;
@@ -654,7 +683,7 @@ public class ChannelDataManagerTest {
}
}
- private class TestChannelDataManagerChannelListener
+ private static class TestChannelDataManagerChannelListener
implements ChannelDataManager.ChannelListener {
public CountDownLatch channelChangedLatch = new CountDownLatch(1);
public final List<Channel> removedChannels = new ArrayList<>();