diff options
Diffstat (limited to 'tests')
26 files changed, 215 insertions, 373 deletions
diff --git a/tests/common/src/com/android/tv/testing/dvr/RecordingTestUtils.java b/tests/common/src/com/android/tv/testing/dvr/RecordingTestUtils.java index a9bfa97a..b9def95e 100644 --- a/tests/common/src/com/android/tv/testing/dvr/RecordingTestUtils.java +++ b/tests/common/src/com/android/tv/testing/dvr/RecordingTestUtils.java @@ -16,7 +16,7 @@ package com.android.tv.testing.dvr; -import com.android.tv.dvr.data.ScheduledRecording; +import com.android.tv.dvr.ScheduledRecording; import junit.framework.Assert; diff --git a/tests/func/src/com/android/tv/tests/ui/LiveChannelsTestCase.java b/tests/func/src/com/android/tv/tests/ui/LiveChannelsTestCase.java index e306e6c6..25c7909b 100644 --- a/tests/func/src/com/android/tv/tests/ui/LiveChannelsTestCase.java +++ b/tests/func/src/com/android/tv/tests/ui/LiveChannelsTestCase.java @@ -73,8 +73,6 @@ public abstract class LiveChannelsTestCase extends InstrumentationTestCase { .hasObject(Constants.PROGRAM_GUIDE)) { mDevice.pressBack(); } - // To destroy the activity to make sure next test case's activity launch check works well. - mDevice.pressBack(); super.tearDown(); } diff --git a/tests/func/src/com/android/tv/tests/ui/PlayControlsRowViewTest.java b/tests/func/src/com/android/tv/tests/ui/PlayControlsRowViewTest.java index 82c6a810..bbc7aa81 100644 --- a/tests/func/src/com/android/tv/tests/ui/PlayControlsRowViewTest.java +++ b/tests/func/src/com/android/tv/tests/ui/PlayControlsRowViewTest.java @@ -16,11 +16,11 @@ package com.android.tv.tests.ui; -import static com.android.tv.testing.uihelper.Constants.CHANNEL_BANNER; import static com.android.tv.testing.uihelper.Constants.FOCUSED_VIEW; import static com.android.tv.testing.uihelper.Constants.MENU; import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertWaitForCondition; +import android.support.test.filters.SdkSuppress; import android.support.test.filters.SmallTest; import android.support.test.uiautomator.BySelector; import android.support.test.uiautomator.UiObject2; @@ -32,8 +32,9 @@ import com.android.tv.testing.testinput.TvTestInputConstants; import com.android.tv.testing.uihelper.DialogHelper; @SmallTest +@SdkSuppress(minSdkVersion = 23) public class PlayControlsRowViewTest extends LiveChannelsTestCase { - private static final String BUTTON_ID_PLAY_PAUSE = "com.android.tv:id/play_pause"; + private static final int BUTTON_INDEX_PLAY_PAUSE = 2; private BySelector mBySettingsSidePanel; @@ -41,9 +42,7 @@ public class PlayControlsRowViewTest extends LiveChannelsTestCase { protected void setUp() throws Exception { super.setUp(); mLiveChannelsHelper.assertAppStarted(); - pressKeysForChannel(TvTestInputConstants.CH_2); - // Wait until KeypadChannelSwitchView closes. - assertWaitForCondition(mDevice, Until.hasObject(CHANNEL_BANNER)); + pressKeysForChannel(TvTestInputConstants.CH_1_DEFAULT_DONT_MODIFY); // Tune to a new channel to ensure that the channel is changed. mDevice.pressDPadUp(); getInstrumentation().waitForIdleSync(); @@ -57,7 +56,7 @@ public class PlayControlsRowViewTest extends LiveChannelsTestCase { public void testFocusedViewInNormalCase() { mMenuHelper.showMenu(); mMenuHelper.assertNavigateToPlayControlsRow(); - assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE); + assertButtonHasFocus(BUTTON_INDEX_PLAY_PAUSE); mDevice.pressBack(); } @@ -70,30 +69,49 @@ public class PlayControlsRowViewTest extends LiveChannelsTestCase { // Fast forward button mDevice.pressKeyCode(KeyEvent.KEYCODE_MEDIA_FAST_FORWARD); mMenuHelper.assertWaitForMenu(); - assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE); + assertButtonHasFocus(BUTTON_INDEX_PLAY_PAUSE); mDevice.pressBack(); // Next button mDevice.pressKeyCode(KeyEvent.KEYCODE_MEDIA_NEXT); mMenuHelper.assertWaitForMenu(); - assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE); + assertButtonHasFocus(BUTTON_INDEX_PLAY_PAUSE); + mDevice.pressBack(); + } + + /** + * Tests the case when the rewinding action is disabled. + * In this case, the button corresponding to the action is disabled, so play/pause button should + * have the focus. + */ + public void testFocusedViewWithDisabledActionBackward() { + // Previous button + mDevice.pressKeyCode(KeyEvent.KEYCODE_MEDIA_PREVIOUS); + mMenuHelper.assertWaitForMenu(); + assertButtonHasFocus(BUTTON_INDEX_PLAY_PAUSE); + mDevice.pressBack(); + + // Rewind button + mDevice.pressKeyCode(KeyEvent.KEYCODE_MEDIA_REWIND); + mMenuHelper.assertWaitForMenu(); + assertButtonHasFocus(BUTTON_INDEX_PLAY_PAUSE); mDevice.pressBack(); } public void testFocusedViewInMenu() { mMenuHelper.showMenu(); mDevice.pressKeyCode(KeyEvent.KEYCODE_MEDIA_PLAY); - assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE); + assertButtonHasFocus(BUTTON_INDEX_PLAY_PAUSE); mMenuHelper.assertNavigateToRow(R.string.menu_title_channels); mDevice.pressKeyCode(KeyEvent.KEYCODE_MEDIA_NEXT); - assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE); + assertButtonHasFocus(BUTTON_INDEX_PLAY_PAUSE); } public void testKeepPausedWhileParentalControlChange() { // Pause the playback. mDevice.pressKeyCode(KeyEvent.KEYCODE_MEDIA_PAUSE); mMenuHelper.assertWaitForMenu(); - assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE); + assertButtonHasFocus(BUTTON_INDEX_PLAY_PAUSE); // Show parental controls fragment. mMenuHelper.assertPressOptionsSettings(); assertWaitForCondition(mDevice, Until.hasObject(mBySettingsSidePanel)); @@ -112,14 +130,14 @@ public class PlayControlsRowViewTest extends LiveChannelsTestCase { mDevice.pressBack(); // Return to the main menu. mMenuHelper.assertWaitForMenu(); - assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE); + assertButtonHasFocus(BUTTON_INDEX_PLAY_PAUSE); } public void testKeepPausedAfterVisitingHome() { // Pause the playback. mDevice.pressKeyCode(KeyEvent.KEYCODE_MEDIA_PAUSE); mMenuHelper.assertWaitForMenu(); - assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE); + assertButtonHasFocus(BUTTON_INDEX_PLAY_PAUSE); // Press HOME twice to visit the home screen and return to Live TV. mDevice.pressHome(); // Wait until home screen is shown. @@ -129,15 +147,19 @@ public class PlayControlsRowViewTest extends LiveChannelsTestCase { mDevice.waitForIdle(); // Return to the main menu. mMenuHelper.assertWaitForMenu(); - assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE); + assertButtonHasFocus(BUTTON_INDEX_PLAY_PAUSE); } - private void assertButtonHasFocus(String buttonId) { + private void assertButtonHasFocus(int expectedButtonIndex) { UiObject2 menu = mDevice.findObject(MENU); UiObject2 focusedView = menu.findObject(FOCUSED_VIEW); assertNotNull("Play controls row doesn't have a focused child.", focusedView); UiObject2 focusedButtonGroup = focusedView.getParent(); assertNotNull("The focused item should have parent", focusedButtonGroup); - assertEquals(buttonId, focusedButtonGroup.getResourceName()); + UiObject2 controlBar = focusedButtonGroup.getParent(); + assertNotNull("The focused item should have grandparent", controlBar); + assertTrue("The grandparent should have more than five children", + controlBar.getChildCount() >= 5); + assertEquals(controlBar.getChildren().get(expectedButtonIndex), focusedButtonGroup); } } diff --git a/tests/input/res/values/strings.xml b/tests/input/res/values/strings.xml index 4ef43955..3f2ab3f7 100644 --- a/tests/input/res/values/strings.xml +++ b/tests/input/res/values/strings.xml @@ -15,6 +15,7 @@ --> <resources> <string name="app_name" translatable="false">Test TV Inputs</string> + <string name="about_app" translatable="false">About TV Test Inputs</string> <string name="version" translatable="false">Version: %1$s</string> <string name="sample_tv_input" translatable="false">Test TV Input</string> <string name="simple_input_label" translatable="false">Test Input</string> diff --git a/tests/jank/src/com/android/tv/tests/jank/ProgramGuideJankTest.java b/tests/jank/src/com/android/tv/tests/jank/ProgramGuideJankTest.java index 03796cfa..7d751c4c 100644 --- a/tests/jank/src/com/android/tv/tests/jank/ProgramGuideJankTest.java +++ b/tests/jank/src/com/android/tv/tests/jank/ProgramGuideJankTest.java @@ -30,6 +30,7 @@ import com.android.tv.testing.uihelper.ByResource; import com.android.tv.testing.uihelper.Constants; import com.android.tv.testing.uihelper.LiveChannelsUiDeviceHelper; import com.android.tv.testing.uihelper.MenuHelper; +import com.android.tv.testing.uihelper.UiDeviceUtils; /** * Jank tests for the program guide. @@ -82,7 +83,7 @@ public class ProgramGuideJankTest extends JankTestBase { } @JankTest(expectedFrames = EXPECTED_FRAMES, - beforeLoop = "showAndFocusProgramGuide", + beforeLoop = "showProgramGuide", afterLoop = "clearProgramGuide") @GfxMonitor(processName = Utils.LIVE_CHANNELS_PROCESS_NAME) public void testScrollDown() { @@ -94,7 +95,7 @@ public class ProgramGuideJankTest extends JankTestBase { } @JankTest(expectedFrames = EXPECTED_FRAMES, - beforeLoop = "showAndFocusProgramGuide", + beforeLoop = "showProgramGuide", afterLoop = "clearProgramGuide") @GfxMonitor(processName = Utils.LIVE_CHANNELS_PROCESS_NAME) public void testScrollRight() { @@ -127,14 +128,8 @@ public class ProgramGuideJankTest extends JankTestBase { assertWaitForCondition(mDevice, Until.gone(Constants.PROGRAM_GUIDE)); } - public void showProgramGuide() { - selectProgramGuideMenuItem(); - mDevice.pressDPadCenter(); - assertWaitForCondition(mDevice, Until.hasObject(Constants.PROGRAM_GUIDE)); - } - // It's public to be used with @JankTest annotation. - public void showAndFocusProgramGuide() { + public void showProgramGuide() { selectProgramGuideMenuItem(); mDevice.pressDPadCenter(); assertWaitForCondition(mDevice, Until.hasObject(Constants.PROGRAM_GUIDE)); diff --git a/tests/unit/src/com/android/tv/MainActivityTest.java b/tests/unit/src/com/android/tv/MainActivityTest.java index 8425597f..b2fe6745 100644 --- a/tests/unit/src/com/android/tv/MainActivityTest.java +++ b/tests/unit/src/com/android/tv/MainActivityTest.java @@ -39,6 +39,7 @@ public class MainActivityTest extends BaseMainActivityTestCase { waitUntilChannelLoadingFinish(); List<Channel> channelList = mActivity.getChannelDataManager().getChannelList(); assertTrue("Expected at least one channel", channelList.size() > 0); + assertFalse("PIP disabled", mActivity.isPipEnabled()); } public void testTuneToChannel() throws Throwable { diff --git a/tests/unit/src/com/android/tv/data/ChannelNumberTest.java b/tests/unit/src/com/android/tv/data/ChannelNumberTest.java index d074baae..4e6e9f3c 100644 --- a/tests/unit/src/com/android/tv/data/ChannelNumberTest.java +++ b/tests/unit/src/com/android/tv/data/ChannelNumberTest.java @@ -42,14 +42,14 @@ public class ChannelNumberTest extends TestCase { */ public void testParseChannelNumber() { assertNull(parseChannelNumber("")); - assertNull(parseChannelNumber("-")); + assertNull(parseChannelNumber(" ")); assertNull(parseChannelNumber("abcd12")); assertNull(parseChannelNumber("12abcd")); assertNull(parseChannelNumber("-12")); assertChannelEquals(parseChannelNumber("1"), "1", false, ""); - assertChannelEquals(parseChannelNumber("1234-4321"), "1234", true, "4321"); + assertChannelEquals(parseChannelNumber("1234 4321"), "1234", true, "4321"); assertChannelEquals(parseChannelNumber("3-4"), "3", true, "4"); - assertChannelEquals(parseChannelNumber("5-6"), "5", true, "6"); + assertChannelEquals(parseChannelNumber("5.6"), "5", true, "6"); } /** @@ -59,11 +59,13 @@ public class ChannelNumberTest extends TestCase { new ComparableTester<ChannelNumber>() .addEquivalentGroup(parseChannelNumber("1"), parseChannelNumber("1")) .addEquivalentGroup(parseChannelNumber("2")) - .addEquivalentGroup(parseChannelNumber("2-1")) + .addEquivalentGroup(parseChannelNumber("2 1"), parseChannelNumber("2.1"), + parseChannelNumber("2-1")) .addEquivalentGroup(parseChannelNumber("2-2")) .addEquivalentGroup(parseChannelNumber("2-10")) .addEquivalentGroup(parseChannelNumber("3")) - .addEquivalentGroup(parseChannelNumber("4"), parseChannelNumber("4-0")) + .addEquivalentGroup(parseChannelNumber("4"), parseChannelNumber("4 0"), + parseChannelNumber("4.0"), parseChannelNumber("4-0")) .addEquivalentGroup(parseChannelNumber("10")) .addEquivalentGroup(parseChannelNumber("100")) .test(); diff --git a/tests/unit/src/com/android/tv/data/ChannelTest.java b/tests/unit/src/com/android/tv/data/ChannelTest.java index f3d80cbe..95e3ee90 100644 --- a/tests/unit/src/com/android/tv/data/ChannelTest.java +++ b/tests/unit/src/com/android/tv/data/ChannelTest.java @@ -226,6 +226,7 @@ public class ChannelTest extends AndroidTestCase { * See <a href="http://b/23031603">b/23031603</a>. */ public void testComparatorLabel() { + TvInputManagerHelper manager = Mockito.mock(TvInputManagerHelper.class); Mockito.when(manager.isPartnerInput(Matchers.anyString())).thenAnswer( new Answer<Boolean>() { @@ -253,29 +254,6 @@ public class ChannelTest extends AndroidTestCase { comparatorTester.test(); } - public void testNormalizeChannelNumber() { - assertNormalizedDisplayNumber(null, null); - assertNormalizedDisplayNumber("", ""); - assertNormalizedDisplayNumber("1", "1"); - assertNormalizedDisplayNumber("abcde", "abcde"); - assertNormalizedDisplayNumber("1-1", "1-1"); - assertNormalizedDisplayNumber("1.1", "1-1"); - assertNormalizedDisplayNumber("1 1", "1-1"); - assertNormalizedDisplayNumber("1\u058a1", "1-1"); - assertNormalizedDisplayNumber("1\u05be1", "1-1"); - assertNormalizedDisplayNumber("1\u14001", "1-1"); - assertNormalizedDisplayNumber("1\u18061", "1-1"); - assertNormalizedDisplayNumber("1\u20101", "1-1"); - assertNormalizedDisplayNumber("1\u20111", "1-1"); - assertNormalizedDisplayNumber("1\u20121", "1-1"); - assertNormalizedDisplayNumber("1\u20131", "1-1"); - assertNormalizedDisplayNumber("1\u20141", "1-1"); - } - - private void assertNormalizedDisplayNumber(String displayNumber, String normalized) { - assertEquals(normalized, Channel.normalizeDisplayNumber(displayNumber)); - } - private class TestChannelComparator extends Channel.DefaultComparator { public TestChannelComparator(TvInputManagerHelper manager) { super(null, manager); diff --git a/tests/unit/src/com/android/tv/data/ProgramTest.java b/tests/unit/src/com/android/tv/data/ProgramTest.java index 08dd17f3..7e474cd6 100644 --- a/tests/unit/src/com/android/tv/data/ProgramTest.java +++ b/tests/unit/src/com/android/tv/data/ProgramTest.java @@ -19,11 +19,13 @@ import static android.media.tv.TvContract.Programs.Genres.COMEDY; import static android.media.tv.TvContract.Programs.Genres.FAMILY_KIDS; import com.android.tv.data.Program.CriticScore; +import com.android.tv.dvr.SeriesRecording; import android.media.tv.TvContentRating; import android.media.tv.TvContract.Programs.Genres; import android.os.Parcel; import android.support.test.filters.SmallTest; +import android.util.Log; import junit.framework.TestCase; diff --git a/tests/unit/src/com/android/tv/dvr/BaseDvrDataManagerTest.java b/tests/unit/src/com/android/tv/dvr/BaseDvrDataManagerTest.java index 6c1b1976..1292759e 100644 --- a/tests/unit/src/com/android/tv/dvr/BaseDvrDataManagerTest.java +++ b/tests/unit/src/com/android/tv/dvr/BaseDvrDataManagerTest.java @@ -21,7 +21,6 @@ import android.support.test.filters.SmallTest; import android.test.AndroidTestCase; import android.test.MoreAsserts; -import com.android.tv.dvr.data.ScheduledRecording; import com.android.tv.testing.FakeClock; import com.android.tv.testing.dvr.RecordingTestUtils; diff --git a/tests/unit/src/com/android/tv/dvr/DvrDataManagerImplTest.java b/tests/unit/src/com/android/tv/dvr/DvrDataManagerImplTest.java index d142f432..b822f164 100644 --- a/tests/unit/src/com/android/tv/dvr/DvrDataManagerImplTest.java +++ b/tests/unit/src/com/android/tv/dvr/DvrDataManagerImplTest.java @@ -18,7 +18,6 @@ package com.android.tv.dvr; import android.support.test.filters.SmallTest; -import com.android.tv.dvr.data.ScheduledRecording; import com.android.tv.testing.dvr.RecordingTestUtils; import junit.framework.TestCase; diff --git a/tests/unit/src/com/android/tv/dvr/DvrDataManagerInMemoryImpl.java b/tests/unit/src/com/android/tv/dvr/DvrDataManagerInMemoryImpl.java index b2164dec..85e35c4d 100644 --- a/tests/unit/src/com/android/tv/dvr/DvrDataManagerInMemoryImpl.java +++ b/tests/unit/src/com/android/tv/dvr/DvrDataManagerInMemoryImpl.java @@ -24,10 +24,7 @@ import android.util.Log; import android.util.Range; import com.android.tv.common.SoftPreconditions; -import com.android.tv.dvr.data.RecordedProgram; -import com.android.tv.dvr.data.ScheduledRecording; -import com.android.tv.dvr.data.ScheduledRecording.RecordingState; -import com.android.tv.dvr.data.SeriesRecording; +import com.android.tv.dvr.ScheduledRecording.RecordingState; import com.android.tv.util.Clock; import java.util.ArrayList; @@ -40,7 +37,7 @@ import java.util.concurrent.atomic.AtomicLong; /** * A DVR Data manager that stores values in memory suitable for testing. */ -public final class DvrDataManagerInMemoryImpl extends BaseDvrDataManager { +final class DvrDataManagerInMemoryImpl extends BaseDvrDataManager { private final static String TAG = "DvrDataManagerInMemory"; private final AtomicLong mNextId = new AtomicLong(1); private final Map<Long, ScheduledRecording> mScheduledRecordings = new HashMap<>(); diff --git a/tests/unit/src/com/android/tv/dvr/provider/DvrDbSyncTest.java b/tests/unit/src/com/android/tv/dvr/DvrDbSyncTest.java index 9e96a7b8..7cb3721c 100644 --- a/tests/unit/src/com/android/tv/dvr/provider/DvrDbSyncTest.java +++ b/tests/unit/src/com/android/tv/dvr/DvrDbSyncTest.java @@ -14,9 +14,8 @@ * limitations under the License */ -package com.android.tv.dvr.provider; +package com.android.tv.dvr; -import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyObject; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.never; @@ -30,11 +29,6 @@ import android.test.AndroidTestCase; import com.android.tv.data.ChannelDataManager; import com.android.tv.data.Program; -import com.android.tv.dvr.DvrDataManagerImpl; -import com.android.tv.dvr.DvrManager; -import com.android.tv.dvr.data.ScheduledRecording; -import com.android.tv.dvr.data.SeriesRecording; -import com.android.tv.dvr.recorder.SeriesRecordingScheduler; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -53,30 +47,20 @@ public class DvrDbSyncTest extends AndroidTestCase { private static final String BASE_EPISODE_NUMBER = "3"; private static final Program BASE_PROGRAM = new Program.Builder().setId(BASE_PROGRAM_ID) .setStartTimeUtcMillis(BASE_START_TIME_MS).setEndTimeUtcMillis(BASE_END_TIME_MS) - .build(); - private static final Program BASE_SERIES_PROGRAM = new Program.Builder().setId(BASE_PROGRAM_ID) - .setStartTimeUtcMillis(BASE_START_TIME_MS).setEndTimeUtcMillis(BASE_END_TIME_MS) .setSeasonNumber(BASE_SEASON_NUMBER).setEpisodeNumber(BASE_EPISODE_NUMBER).build(); private static final ScheduledRecording BASE_SCHEDULE = ScheduledRecording.builder(INPUT_ID, BASE_PROGRAM).build(); - private static final ScheduledRecording BASE_SERIES_SCHEDULE = - ScheduledRecording.builder(INPUT_ID, BASE_SERIES_PROGRAM).build(); private DvrDbSync mDbSync; - @Mock private DvrManager mDvrManager; @Mock private DvrDataManagerImpl mDataManager; @Mock private ChannelDataManager mChannelDataManager; - @Mock private SeriesRecordingScheduler mSeriesRecordingScheduler; @Override protected void setUp() throws Exception { super.setUp(); MockitoAnnotations.initMocks(this); when(mChannelDataManager.isDbLoadFinished()).thenReturn(true); - when(mDvrManager.addSeriesRecording(anyObject(), anyObject(), anyInt())) - .thenReturn(SeriesRecording.builder(INPUT_ID, BASE_PROGRAM).build()); - mDbSync = new DvrDbSync(getContext(), mDataManager, mChannelDataManager, - mDvrManager, mSeriesRecordingScheduler); + mDbSync = new DvrDbSync(getContext(), mDataManager, mChannelDataManager); } public void testHandleUpdateProgram_null() { @@ -106,21 +90,21 @@ public class DvrDbSyncTest extends AndroidTestCase { } public void testHandleUpdateProgram_changeSeason() { - addSchedule(BASE_PROGRAM_ID, BASE_SERIES_SCHEDULE); + addSchedule(BASE_PROGRAM_ID, BASE_SCHEDULE); String seasonNumber = BASE_SEASON_NUMBER + "1"; String episodeNumber = BASE_EPISODE_NUMBER + "1"; - Program program = new Program.Builder(BASE_SERIES_PROGRAM).setSeasonNumber(seasonNumber) + Program program = new Program.Builder(BASE_PROGRAM).setSeasonNumber(seasonNumber) .setEpisodeNumber(episodeNumber).build(); mDbSync.handleUpdateProgram(program, BASE_PROGRAM_ID); assertUpdateScheduleCalled(program); } public void testHandleUpdateProgram_finished() { - addSchedule(BASE_PROGRAM_ID, ScheduledRecording.buildFrom(BASE_SERIES_SCHEDULE) + addSchedule(BASE_PROGRAM_ID, ScheduledRecording.buildFrom(BASE_SCHEDULE) .setState(ScheduledRecording.STATE_RECORDING_FINISHED).build()); String seasonNumber = BASE_SEASON_NUMBER + "1"; String episodeNumber = BASE_EPISODE_NUMBER + "1"; - Program program = new Program.Builder(BASE_SERIES_PROGRAM).setSeasonNumber(seasonNumber) + Program program = new Program.Builder(BASE_PROGRAM).setSeasonNumber(seasonNumber) .setEpisodeNumber(episodeNumber).build(); mDbSync.handleUpdateProgram(program, BASE_PROGRAM_ID); verify(mDataManager, never()).updateScheduledRecording(anyObject()); diff --git a/tests/unit/src/com/android/tv/dvr/recorder/DvrRecordingServiceTest.java b/tests/unit/src/com/android/tv/dvr/DvrRecordingServiceTest.java index 7ad8d55d..0a203ede 100644 --- a/tests/unit/src/com/android/tv/dvr/recorder/DvrRecordingServiceTest.java +++ b/tests/unit/src/com/android/tv/dvr/DvrRecordingServiceTest.java @@ -14,7 +14,7 @@ * limitations under the License */ -package com.android.tv.dvr.recorder; +package com.android.tv.dvr; import static org.mockito.Mockito.verify; diff --git a/tests/unit/src/com/android/tv/dvr/DvrScheduleManagerTest.java b/tests/unit/src/com/android/tv/dvr/DvrScheduleManagerTest.java index cfb27211..2850a5f7 100644 --- a/tests/unit/src/com/android/tv/dvr/DvrScheduleManagerTest.java +++ b/tests/unit/src/com/android/tv/dvr/DvrScheduleManagerTest.java @@ -20,8 +20,6 @@ import android.support.test.filters.SmallTest; import android.test.MoreAsserts; import android.util.Range; -import com.android.tv.dvr.DvrScheduleManager.ConflictInfo; -import com.android.tv.dvr.data.ScheduledRecording; import com.android.tv.testing.dvr.RecordingTestUtils; import junit.framework.TestCase; @@ -30,6 +28,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; /** * Tests for {@link DvrScheduleManager} @@ -587,80 +586,49 @@ public class DvrScheduleManagerTest extends TestCase { RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(++channelId, --priority, 50L, 900L) )); - List<ConflictInfo> conflicts = DvrScheduleManager.getConflictingSchedulesInfo(schedules, 1); - - assertNotInList(schedules.get(0), conflicts); - assertFullConflict(schedules.get(1), conflicts); - assertPartialConflict(schedules.get(2), conflicts); - assertPartialConflict(schedules.get(3), conflicts); - assertNotInList(schedules.get(4), conflicts); - assertPartialConflict(schedules.get(5), conflicts); - assertNotInList(schedules.get(6), conflicts); - assertFullConflict(schedules.get(7), conflicts); - assertFullConflict(schedules.get(8), conflicts); - assertFullConflict(schedules.get(9), conflicts); - assertFullConflict(schedules.get(10), conflicts); - - conflicts = DvrScheduleManager.getConflictingSchedulesInfo(schedules, 2); - - assertNotInList(schedules.get(0), conflicts); - assertNotInList(schedules.get(1), conflicts); - assertNotInList(schedules.get(2), conflicts); - assertNotInList(schedules.get(3), conflicts); - assertNotInList(schedules.get(4), conflicts); - assertNotInList(schedules.get(5), conflicts); - assertNotInList(schedules.get(6), conflicts); - assertFullConflict(schedules.get(7), conflicts); - assertFullConflict(schedules.get(8), conflicts); - assertFullConflict(schedules.get(9), conflicts); - assertPartialConflict(schedules.get(10), conflicts); - - conflicts = DvrScheduleManager.getConflictingSchedulesInfo(schedules, 3); - - assertNotInList(schedules.get(0), conflicts); - assertNotInList(schedules.get(1), conflicts); - assertNotInList(schedules.get(2), conflicts); - assertNotInList(schedules.get(3), conflicts); - assertNotInList(schedules.get(4), conflicts); - assertNotInList(schedules.get(5), conflicts); - assertNotInList(schedules.get(6), conflicts); - assertNotInList(schedules.get(7), conflicts); - assertPartialConflict(schedules.get(8), conflicts); - assertNotInList(schedules.get(9), conflicts); - assertPartialConflict(schedules.get(10), conflicts); - } - - private void assertNotInList(ScheduledRecording schedule, List<ConflictInfo> conflicts) { - for (ConflictInfo conflictInfo : conflicts) { - if (conflictInfo.schedule.equals(schedule)) { - fail(schedule + " conflicts with others."); - } - } - } - - private void assertPartialConflict(ScheduledRecording schedule, List<ConflictInfo> conflicts) { - for (ConflictInfo conflictInfo : conflicts) { - if (conflictInfo.schedule.equals(schedule)) { - if (conflictInfo.partialConflict) { - return; - } else { - fail(schedule + " fully conflicts with others."); - } - } - } - fail(schedule + " doesn't conflict"); - } - - private void assertFullConflict(ScheduledRecording schedule, List<ConflictInfo> conflicts) { - for (ConflictInfo conflictInfo : conflicts) { - if (conflictInfo.schedule.equals(schedule)) { - if (!conflictInfo.partialConflict) { - return; - } else { - fail(schedule + " partially conflicts with others."); - } - } - } - fail(schedule + " doesn't conflict"); + Map<ScheduledRecording, Boolean> conflictsInfo = DvrScheduleManager + .getConflictingSchedulesInfo(schedules, 1); + + assertNull(conflictsInfo.get(schedules.get(0))); + assertFalse(conflictsInfo.get(schedules.get(1))); + assertTrue(conflictsInfo.get(schedules.get(2))); + assertTrue(conflictsInfo.get(schedules.get(3))); + assertNull(conflictsInfo.get(schedules.get(4))); + assertTrue(conflictsInfo.get(schedules.get(5))); + assertNull(conflictsInfo.get(schedules.get(6))); + assertFalse(conflictsInfo.get(schedules.get(7))); + assertFalse(conflictsInfo.get(schedules.get(8))); + assertFalse(conflictsInfo.get(schedules.get(9))); + assertFalse(conflictsInfo.get(schedules.get(10))); + + conflictsInfo = DvrScheduleManager + .getConflictingSchedulesInfo(schedules, 2); + + assertNull(conflictsInfo.get(schedules.get(0))); + assertNull(conflictsInfo.get(schedules.get(1))); + assertNull(conflictsInfo.get(schedules.get(2))); + assertNull(conflictsInfo.get(schedules.get(3))); + assertNull(conflictsInfo.get(schedules.get(4))); + assertNull(conflictsInfo.get(schedules.get(5))); + assertNull(conflictsInfo.get(schedules.get(6))); + assertFalse(conflictsInfo.get(schedules.get(7))); + assertFalse(conflictsInfo.get(schedules.get(8))); + assertFalse(conflictsInfo.get(schedules.get(9))); + assertTrue(conflictsInfo.get(schedules.get(10))); + + conflictsInfo = DvrScheduleManager + .getConflictingSchedulesInfo(schedules, 3); + + assertNull(conflictsInfo.get(schedules.get(0))); + assertNull(conflictsInfo.get(schedules.get(1))); + assertNull(conflictsInfo.get(schedules.get(2))); + assertNull(conflictsInfo.get(schedules.get(3))); + assertNull(conflictsInfo.get(schedules.get(4))); + assertNull(conflictsInfo.get(schedules.get(5))); + assertNull(conflictsInfo.get(schedules.get(6))); + assertNull(conflictsInfo.get(schedules.get(7))); + assertTrue(conflictsInfo.get(schedules.get(8))); + assertNull(conflictsInfo.get(schedules.get(9))); + assertTrue(conflictsInfo.get(schedules.get(10))); } }
\ No newline at end of file diff --git a/tests/unit/src/com/android/tv/dvr/EpisodicProgramLoadTaskTest.java b/tests/unit/src/com/android/tv/dvr/EpisodicProgramLoadTaskTest.java new file mode 100644 index 00000000..2172d488 --- /dev/null +++ b/tests/unit/src/com/android/tv/dvr/EpisodicProgramLoadTaskTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.tv.dvr; + +import android.os.Build; +import android.support.test.filters.SdkSuppress; +import android.support.test.filters.SmallTest; +import android.test.AndroidTestCase; + +import com.android.tv.dvr.EpisodicProgramLoadTask.ScheduledEpisode; + +import java.util.ArrayList; +import java.util.List; + +/** + * Tests for {@link EpisodicProgramLoadTask} + */ +@SmallTest +@SdkSuppress(minSdkVersion = Build.VERSION_CODES.N) +public class EpisodicProgramLoadTaskTest extends AndroidTestCase { + private static final long SERIES_RECORDING_ID1 = 1; + private static final long SERIES_RECORDING_ID2 = 2; + private static final String SEASON_NUMBER1 = "SEASON NUMBER1"; + private static final String SEASON_NUMBER2 = "SEASON NUMBER2"; + private static final String EPISODE_NUMBER1 = "EPISODE NUMBER1"; + private static final String EPISODE_NUMBER2 = "EPISODE NUMBER2"; + + public void testEpisodeAlreadyScheduled_true() { + List<ScheduledEpisode> episodes = new ArrayList<>(); + ScheduledEpisode episode = new ScheduledEpisode(SERIES_RECORDING_ID1, SEASON_NUMBER1, + EPISODE_NUMBER1); + episodes.add(episode); + assertTrue(EpisodicProgramLoadTask.isEpisodeScheduled(episodes, + new ScheduledEpisode(SERIES_RECORDING_ID1, SEASON_NUMBER1, EPISODE_NUMBER1))); + } + + public void testEpisodeAlreadyScheduled_false() { + List<ScheduledEpisode> episodes = new ArrayList<>(); + ScheduledEpisode episode = new ScheduledEpisode(SERIES_RECORDING_ID1, SEASON_NUMBER1, + EPISODE_NUMBER1); + episodes.add(episode); + assertFalse(EpisodicProgramLoadTask.isEpisodeScheduled(episodes, + new ScheduledEpisode(SERIES_RECORDING_ID2, SEASON_NUMBER1, EPISODE_NUMBER1))); + assertFalse(EpisodicProgramLoadTask.isEpisodeScheduled(episodes, + new ScheduledEpisode(SERIES_RECORDING_ID1, SEASON_NUMBER2, EPISODE_NUMBER1))); + assertFalse(EpisodicProgramLoadTask.isEpisodeScheduled(episodes, + new ScheduledEpisode(SERIES_RECORDING_ID1, SEASON_NUMBER1, EPISODE_NUMBER2))); + } + + public void testEpisodeAlreadyScheduled_null() { + List<ScheduledEpisode> episodes = new ArrayList<>(); + ScheduledEpisode episode = new ScheduledEpisode(SERIES_RECORDING_ID1, SEASON_NUMBER1, + EPISODE_NUMBER1); + episodes.add(episode); + assertFalse(EpisodicProgramLoadTask.isEpisodeScheduled(episodes, + new ScheduledEpisode(SERIES_RECORDING_ID1, null, EPISODE_NUMBER1))); + assertFalse(EpisodicProgramLoadTask.isEpisodeScheduled(episodes, + new ScheduledEpisode(SERIES_RECORDING_ID1, SEASON_NUMBER1, null))); + assertFalse(EpisodicProgramLoadTask.isEpisodeScheduled(episodes, + new ScheduledEpisode(SERIES_RECORDING_ID1, null, null))); + } +} diff --git a/tests/unit/src/com/android/tv/dvr/recorder/InputTaskSchedulerTest.java b/tests/unit/src/com/android/tv/dvr/InputTaskSchedulerTest.java index ef0d5fab..85c78ce2 100644 --- a/tests/unit/src/com/android/tv/dvr/recorder/InputTaskSchedulerTest.java +++ b/tests/unit/src/com/android/tv/dvr/InputTaskSchedulerTest.java @@ -14,11 +14,12 @@ * limitations under the License */ -package com.android.tv.dvr.recorder; +package com.android.tv.dvr; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyLong; import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.after; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.verify; @@ -36,10 +37,7 @@ import android.test.AndroidTestCase; import com.android.tv.InputSessionManager; import com.android.tv.data.Channel; import com.android.tv.data.ChannelDataManager; -import com.android.tv.dvr.DvrManager; -import com.android.tv.dvr.WritableDvrDataManager; -import com.android.tv.dvr.data.ScheduledRecording; -import com.android.tv.dvr.recorder.InputTaskScheduler.RecordingTaskFactory; +import com.android.tv.dvr.InputTaskScheduler.RecordingTaskFactory; import com.android.tv.testing.FakeClock; import com.android.tv.testing.dvr.RecordingTestUtils; import com.android.tv.util.Clock; @@ -145,7 +143,7 @@ public class InputTaskSchedulerTest extends AndroidTestCase { verify(mRecordingTasks.get(0), timeout((int) LISTENER_TIMEOUT_MS).times(1)).start(); // The first schedule should not be stopped because the second one should wait for the end // of the first schedule. - verify(mRecordingTasks.get(0), timeout((int) LISTENER_TIMEOUT_MS).never()).stop(); + verify(mRecordingTasks.get(0), after((int) LISTENER_TIMEOUT_MS).never()).stop(); } public void testAddSchedule_consecutiveNoFail() throws Exception { @@ -165,9 +163,9 @@ public class InputTaskSchedulerTest extends AndroidTestCase { LOW_PRIORITY, startTimeMs, endTimeMs)); mScheduler.handleBuildSchedule(); verify(mRecordingTasks.get(0), timeout((int) LISTENER_TIMEOUT_MS).times(1)).start(); - verify(mRecordingTasks.get(0), timeout((int) LISTENER_TIMEOUT_MS).never()).stop(); + verify(mRecordingTasks.get(0), after((int) LISTENER_TIMEOUT_MS).never()).stop(); // The second schedule should not fail because it can starts after the first one finishes. - verify(mDataManager, timeout((int) LISTENER_TIMEOUT_MS).never()) + verify(mDataManager, after((int) LISTENER_TIMEOUT_MS).never()) .changeState(any(ScheduledRecording.class), eq(ScheduledRecording.STATE_RECORDING_FAILED)); } @@ -189,7 +187,7 @@ public class InputTaskSchedulerTest extends AndroidTestCase { HIGH_PRIORITY, startTimeMs, endTimeMs)); mScheduler.handleBuildSchedule(); verify(mRecordingTasks.get(0), timeout((int) LISTENER_TIMEOUT_MS).times(1)).start(); - verify(mRecordingTasks.get(0), timeout((int) LISTENER_TIMEOUT_MS).never()).stop(); + verify(mRecordingTasks.get(0), after((int) LISTENER_TIMEOUT_MS).never()).stop(); // The second schedule should wait until the first one finishes rather than creating a new // session even though there are available tuners. assertTrue(mRecordingTasks.size() == 1); @@ -202,7 +200,7 @@ public class InputTaskSchedulerTest extends AndroidTestCase { mScheduler.handleAddSchedule(r); mScheduler.handleBuildSchedule(); mScheduler.handleUpdateSchedule(r); - verify(mRecordingTasks.get(0), timeout((int) LISTENER_TIMEOUT_MS).never()).cancel(); + verify(mRecordingTasks.get(0), after((int) LISTENER_TIMEOUT_MS).never()).cancel(); } public void testUpdateSchedule_cancel() throws Exception { diff --git a/tests/unit/src/com/android/tv/dvr/recorder/RecordingTaskTest.java b/tests/unit/src/com/android/tv/dvr/RecordingTaskTest.java index 076773e7..7404a554 100644 --- a/tests/unit/src/com/android/tv/dvr/recorder/RecordingTaskTest.java +++ b/tests/unit/src/com/android/tv/dvr/RecordingTaskTest.java @@ -14,17 +14,17 @@ * limitations under the License */ -package com.android.tv.dvr.recorder; +package com.android.tv.dvr; import static org.mockito.Matchers.anyLong; import static org.mockito.Matchers.anyObject; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.argThat; import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.longThat; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; +import static org.mockito.hamcrest.MockitoHamcrest.longThat; import android.os.Build; import android.os.Handler; @@ -37,18 +37,15 @@ import android.test.AndroidTestCase; import com.android.tv.InputSessionManager; import com.android.tv.InputSessionManager.RecordingSession; import com.android.tv.data.Channel; -import com.android.tv.dvr.DvrDataManagerInMemoryImpl; -import com.android.tv.dvr.DvrManager; -import com.android.tv.dvr.data.ScheduledRecording; -import com.android.tv.dvr.recorder.RecordingTask.State; +import com.android.tv.dvr.RecordingTask.State; import com.android.tv.testing.FakeClock; import com.android.tv.testing.dvr.RecordingTestUtils; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; -import org.mockito.ArgumentMatcher; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.mockito.compat.ArgumentMatcher; import java.util.concurrent.TimeUnit; @@ -160,10 +157,10 @@ public class RecordingTaskTest extends AndroidTestCase { private static ArgumentMatcher<Message> messageMatchesWhat(final int what) { return new ArgumentMatcher<Message>() { @Override - public boolean matches(Object argument) { + public boolean matchesObject(Object argument) { Message message = (Message) argument; return message.what == what; } }; } -}
\ No newline at end of file +} diff --git a/tests/unit/src/com/android/tv/dvr/recorder/ScheduledProgramReaperTest.java b/tests/unit/src/com/android/tv/dvr/ScheduledProgramReaperTest.java index d434a34e..847540c2 100644 --- a/tests/unit/src/com/android/tv/dvr/recorder/ScheduledProgramReaperTest.java +++ b/tests/unit/src/com/android/tv/dvr/ScheduledProgramReaperTest.java @@ -14,20 +14,15 @@ * limitations under the License. */ -package com.android.tv.dvr.recorder; +package com.android.tv.dvr; -import android.os.Build; -import android.support.test.filters.SdkSuppress; -import android.support.test.filters.SmallTest; -import android.test.AndroidTestCase; import android.test.MoreAsserts; -import com.android.tv.dvr.DvrDataManagerInMemoryImpl; -import com.android.tv.dvr.DvrManager; -import com.android.tv.dvr.data.ScheduledRecording; import com.android.tv.testing.FakeClock; import com.android.tv.testing.dvr.RecordingTestUtils; +import junit.framework.TestCase; + import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -36,9 +31,7 @@ import java.util.concurrent.TimeUnit; /** * Tests for {@link ScheduledProgramReaper}. */ -@SmallTest -@SdkSuppress(minSdkVersion = Build.VERSION_CODES.N) -public class ScheduledProgramReaperTest extends AndroidTestCase { +public class ScheduledProgramReaperTest extends TestCase { private static final String INPUT_ID = "input_id"; private static final int CHANNEL_ID = 273; private static final long DURATION = TimeUnit.HOURS.toMillis(1); @@ -48,12 +41,13 @@ public class ScheduledProgramReaperTest extends AndroidTestCase { private DvrDataManagerInMemoryImpl mDvrDataManager; @Mock private DvrManager mDvrManager; + @Override protected void setUp() throws Exception { super.setUp(); MockitoAnnotations.initMocks(this); mFakeClock = FakeClock.createWithTimeOne(); - mDvrDataManager = new DvrDataManagerInMemoryImpl(getContext(), mFakeClock); + mDvrDataManager = new DvrDataManagerInMemoryImpl(null, mFakeClock); mReaper = new ScheduledProgramReaper(mDvrDataManager, mFakeClock); } diff --git a/tests/unit/src/com/android/tv/dvr/ScheduledRecordingTest.java b/tests/unit/src/com/android/tv/dvr/ScheduledRecordingTest.java index 426e60ba..96036418 100644 --- a/tests/unit/src/com/android/tv/dvr/ScheduledRecordingTest.java +++ b/tests/unit/src/com/android/tv/dvr/ScheduledRecordingTest.java @@ -26,7 +26,6 @@ import android.util.Range; import com.android.tv.data.Channel; import com.android.tv.data.Program; -import com.android.tv.dvr.data.ScheduledRecording; import com.android.tv.testing.dvr.RecordingTestUtils; import junit.framework.TestCase; diff --git a/tests/unit/src/com/android/tv/dvr/recorder/SchedulerTest.java b/tests/unit/src/com/android/tv/dvr/SchedulerTest.java index 94cfaac1..30ac1ff1 100644 --- a/tests/unit/src/com/android/tv/dvr/recorder/SchedulerTest.java +++ b/tests/unit/src/com/android/tv/dvr/SchedulerTest.java @@ -14,7 +14,7 @@ * limitations under the License */ -package com.android.tv.dvr.recorder; +package com.android.tv.dvr; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; @@ -31,9 +31,6 @@ import android.test.AndroidTestCase; import com.android.tv.InputSessionManager; import com.android.tv.data.ChannelDataManager; -import com.android.tv.dvr.DvrDataManagerInMemoryImpl; -import com.android.tv.dvr.DvrManager; -import com.android.tv.dvr.data.ScheduledRecording; import com.android.tv.testing.FakeClock; import com.android.tv.testing.dvr.RecordingTestUtils; import com.android.tv.util.TvInputManagerHelper; @@ -87,13 +84,13 @@ public class SchedulerTest extends AndroidTestCase { startTime + TimeUnit.HOURS.toMillis(1)); mDataManager.addScheduledRecording(r); mScheduler.start(); - verify(mMockAlarmManager).setExactAndAllowWhileIdle( + verify(mMockAlarmManager).set( eq(AlarmManager.RTC_WAKEUP), eq(startTime - Scheduler.MS_TO_WAKE_BEFORE_START), any(PendingIntent.class)); Mockito.reset(mMockAlarmManager); mScheduler.update(); - verify(mMockAlarmManager).setExactAndAllowWhileIdle( + verify(mMockAlarmManager).set( eq(AlarmManager.RTC_WAKEUP), eq(startTime - Scheduler.MS_TO_WAKE_BEFORE_START), any(PendingIntent.class)); diff --git a/tests/unit/src/com/android/tv/dvr/recorder/SeriesRecordingSchedulerTest.java b/tests/unit/src/com/android/tv/dvr/SeriesRecordingSchedulerTest.java index afb9c042..efefb93c 100644 --- a/tests/unit/src/com/android/tv/dvr/recorder/SeriesRecordingSchedulerTest.java +++ b/tests/unit/src/com/android/tv/dvr/SeriesRecordingSchedulerTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.tv.dvr.recorder; +package com.android.tv.dvr; import android.os.Build; import android.support.test.filters.SdkSuppress; @@ -24,8 +24,6 @@ import android.test.MoreAsserts; import android.util.LongSparseArray; import com.android.tv.data.Program; -import com.android.tv.dvr.DvrDataManagerInMemoryImpl; -import com.android.tv.dvr.data.SeriesRecording; import com.android.tv.testing.FakeClock; import java.util.ArrayList; diff --git a/tests/unit/src/com/android/tv/dvr/data/SeriesRecordingTest.java b/tests/unit/src/com/android/tv/dvr/SeriesRecordingTest.java index 7512ed0e..c48fec02 100644 --- a/tests/unit/src/com/android/tv/dvr/data/SeriesRecordingTest.java +++ b/tests/unit/src/com/android/tv/dvr/SeriesRecordingTest.java @@ -14,7 +14,7 @@ * limitations under the License */ -package com.android.tv.dvr.data; +package com.android.tv.dvr; import android.os.Build; import android.os.Parcel; diff --git a/tests/unit/src/com/android/tv/dvr/provider/EpisodicProgramLoadTaskTest.java b/tests/unit/src/com/android/tv/dvr/provider/EpisodicProgramLoadTaskTest.java deleted file mode 100644 index 301c453d..00000000 --- a/tests/unit/src/com/android/tv/dvr/provider/EpisodicProgramLoadTaskTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tv.dvr.provider; - -import android.os.Build; -import android.support.test.filters.SdkSuppress; -import android.support.test.filters.SmallTest; -import android.test.AndroidTestCase; - -import com.android.tv.dvr.data.SeasonEpisodeNumber; - -import java.util.ArrayList; -import java.util.List; - -/** - * Tests for {@link EpisodicProgramLoadTask} - */ -@SmallTest -@SdkSuppress(minSdkVersion = Build.VERSION_CODES.N) -public class EpisodicProgramLoadTaskTest extends AndroidTestCase { - private static final long SERIES_RECORDING_ID1 = 1; - private static final long SERIES_RECORDING_ID2 = 2; - private static final String SEASON_NUMBER1 = "SEASON NUMBER1"; - private static final String SEASON_NUMBER2 = "SEASON NUMBER2"; - private static final String EPISODE_NUMBER1 = "EPISODE NUMBER1"; - private static final String EPISODE_NUMBER2 = "EPISODE NUMBER2"; - - public void testEpisodeAlreadyScheduled_true() { - List<SeasonEpisodeNumber> seasonEpisodeNumbers = new ArrayList<>(); - SeasonEpisodeNumber seasonEpisodeNumber = new SeasonEpisodeNumber( - SERIES_RECORDING_ID1, SEASON_NUMBER1, EPISODE_NUMBER1); - seasonEpisodeNumbers.add(seasonEpisodeNumber); - assertTrue(seasonEpisodeNumbers.contains( - new SeasonEpisodeNumber(SERIES_RECORDING_ID1, SEASON_NUMBER1, EPISODE_NUMBER1))); - } - - public void testEpisodeAlreadyScheduled_false() { - List<SeasonEpisodeNumber> seasonEpisodeNumbers = new ArrayList<>(); - SeasonEpisodeNumber seasonEpisodeNumber = new SeasonEpisodeNumber( - SERIES_RECORDING_ID1, SEASON_NUMBER1, EPISODE_NUMBER1); - seasonEpisodeNumbers.add(seasonEpisodeNumber); - assertFalse(seasonEpisodeNumbers.contains( - new SeasonEpisodeNumber(SERIES_RECORDING_ID2, SEASON_NUMBER1, EPISODE_NUMBER1))); - assertFalse(seasonEpisodeNumbers.contains( - new SeasonEpisodeNumber(SERIES_RECORDING_ID1, SEASON_NUMBER2, EPISODE_NUMBER1))); - assertFalse(seasonEpisodeNumbers.contains( - new SeasonEpisodeNumber(SERIES_RECORDING_ID1, SEASON_NUMBER1, EPISODE_NUMBER2))); - } - - public void testEpisodeAlreadyScheduled_null() { - List<SeasonEpisodeNumber> seasonEpisodeNumbers = new ArrayList<>(); - SeasonEpisodeNumber seasonEpisodeNumber = new SeasonEpisodeNumber( - SERIES_RECORDING_ID1, SEASON_NUMBER1, EPISODE_NUMBER1); - seasonEpisodeNumbers.add(seasonEpisodeNumber); - assertFalse(seasonEpisodeNumbers.contains( - new SeasonEpisodeNumber(SERIES_RECORDING_ID1, null, EPISODE_NUMBER1))); - assertFalse(seasonEpisodeNumbers.contains( - new SeasonEpisodeNumber(SERIES_RECORDING_ID1, SEASON_NUMBER1, null))); - assertFalse(seasonEpisodeNumbers.contains( - new SeasonEpisodeNumber(SERIES_RECORDING_ID1, null, null))); - } -}
\ No newline at end of file diff --git a/tests/unit/src/com/android/tv/dvr/ui/SortedArrayAdapterTest.java b/tests/unit/src/com/android/tv/dvr/ui/SortedArrayAdapterTest.java index 8fc8270f..a571e626 100644 --- a/tests/unit/src/com/android/tv/dvr/ui/SortedArrayAdapterTest.java +++ b/tests/unit/src/com/android/tv/dvr/ui/SortedArrayAdapterTest.java @@ -32,10 +32,10 @@ import java.util.Objects; @SmallTest public class SortedArrayAdapterTest extends TestCase { - public static final TestData P1 = TestData.create(1, "c"); - public static final TestData P2 = TestData.create(2, "b"); - public static final TestData P3 = TestData.create(3, "a"); - public static final TestData EXTRA = TestData.create(4, "k"); + public static final TestData P1 = TestData.create(1, "one"); + public static final TestData P2 = TestData.create(2, "before"); + public static final TestData P3 = TestData.create(3, "other"); + public static final TestData EXTRA = TestData.create(4, "extra"); private TestSortedArrayAdapter mAdapter; @Override @@ -111,43 +111,6 @@ public class SortedArrayAdapterTest extends TestCase { assertContentsInOrder(mAdapter, P1); mAdapter.remove(P1); assertEmpty(); - mAdapter.add(P1); - mAdapter.add(P2); - mAdapter.add(P3); - assertContentsInOrder(mAdapter, P3, P2, P1); - mAdapter.removeItems(0, 2); - assertContentsInOrder(mAdapter, P1); - mAdapter.add(P2); - mAdapter.add(P3); - mAdapter.addExtraItem(EXTRA); - assertContentsInOrder(mAdapter, P3, P2, P1, EXTRA); - mAdapter.removeItems(1, 1); - assertContentsInOrder(mAdapter, P3, P1, EXTRA); - mAdapter.removeItems(1, 2); - assertContentsInOrder(mAdapter, P3); - mAdapter.addExtraItem(EXTRA); - mAdapter.addExtraItem(P2); - mAdapter.add(P1); - assertContentsInOrder(mAdapter, P3, P1, EXTRA, P2); - mAdapter.removeItems(1, 2); - assertContentsInOrder(mAdapter, P3, P2); - mAdapter.add(P1); - assertContentsInOrder(mAdapter, P3, P1, P2); - } - - public void testReplace() { - mAdapter.add(P1); - mAdapter.add(P2); - assertNotEmpty(); - assertContentsInOrder(mAdapter, P2, P1); - mAdapter.replace(1, P3); - assertContentsInOrder(mAdapter, P3, P2); - mAdapter.replace(0, P1); - assertContentsInOrder(mAdapter, P2, P1); - mAdapter.addExtraItem(EXTRA); - assertContentsInOrder(mAdapter, P2, P1, EXTRA); - mAdapter.replace(2, P3); - assertContentsInOrder(mAdapter, P2, P1, P3); } public void testChange_sorting() { @@ -231,7 +194,7 @@ public class SortedArrayAdapterTest extends TestCase { } @Override - protected long getId(TestData item) { + long getId(TestData item) { return item.mId; } } diff --git a/tests/unit/src/com/android/tv/experiments/ExperimentsTest.java b/tests/unit/src/com/android/tv/experiments/ExperimentsTest.java deleted file mode 100644 index ab709e39..00000000 --- a/tests/unit/src/com/android/tv/experiments/ExperimentsTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.tv.experiments; - -import android.support.test.filters.SmallTest; - -import com.android.tv.common.BuildConfig; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.List; - -/** - * Tests for {@link Experiments}. - */ -@SmallTest -public class ExperimentsTest extends TestCase { - - @Override - protected void setUp() throws Exception { - super.setUp(); - ExperimentFlag.initForTest(); - } - - - public void testEngOnlyDefault() { - assertEquals("ENABLE_DEVELOPER_FEATURES", Boolean.valueOf(BuildConfig.ENG), - Experiments.ENABLE_DEVELOPER_FEATURES.get()); - } - - -} |