diff options
author | Youngsang Cho <youngsang@google.com> | 2016-10-31 15:28:42 -0700 |
---|---|---|
committer | Youngsang Cho <youngsang@google.com> | 2016-10-31 15:28:42 -0700 |
commit | 919e1ed7e914029a1a0054237d86dc7b19ced898 (patch) | |
tree | cb30cfbafd80e01d314868cdc36e783d39981119 /tests/unit/src/com/android/tv/dvr/SchedulerTest.java | |
parent | 2933fcfd17f59c086436b270e7c01f2afcd54aa5 (diff) | |
download | TV-919e1ed7e914029a1a0054237d86dc7b19ced898.tar.gz |
Sync to ub-tv-killing at 6f6e46557accb62c9548e4177d6005aa944dbf33
Change-Id: I873644d6d9d0110c981ef6075cb4019c16bbb94b
Diffstat (limited to 'tests/unit/src/com/android/tv/dvr/SchedulerTest.java')
-rw-r--r-- | tests/unit/src/com/android/tv/dvr/SchedulerTest.java | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/tests/unit/src/com/android/tv/dvr/SchedulerTest.java b/tests/unit/src/com/android/tv/dvr/SchedulerTest.java index 140d9091..30ac1ff1 100644 --- a/tests/unit/src/com/android/tv/dvr/SchedulerTest.java +++ b/tests/unit/src/com/android/tv/dvr/SchedulerTest.java @@ -16,7 +16,6 @@ package com.android.tv.dvr; - import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; @@ -27,14 +26,17 @@ import android.app.PendingIntent; import android.os.Build; import android.os.Looper; import android.support.test.filters.SdkSuppress; +import android.support.test.filters.SmallTest; import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.SmallTest; +import com.android.tv.InputSessionManager; import com.android.tv.data.ChannelDataManager; import com.android.tv.testing.FakeClock; import com.android.tv.testing.dvr.RecordingTestUtils; +import com.android.tv.util.TvInputManagerHelper; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import java.util.concurrent.TimeUnit; @@ -45,16 +47,17 @@ import java.util.concurrent.TimeUnit; @SmallTest @SdkSuppress(minSdkVersion = Build.VERSION_CODES.N) public class SchedulerTest extends AndroidTestCase { + private static final String INPUT_ID = "input_id"; private static final int CHANNEL_ID = 273; private FakeClock mFakeClock; private DvrDataManagerInMemoryImpl mDataManager; private Scheduler mScheduler; @Mock DvrManager mDvrManager; - @Mock DvrSessionManager mSessionManager; + @Mock InputSessionManager mSessionManager; @Mock AlarmManager mMockAlarmManager; - @Mock - ChannelDataManager mChannelDataManager; + @Mock ChannelDataManager mChannelDataManager; + @Mock TvInputManagerHelper mInputManager; @Override protected void setUp() throws Exception { @@ -62,11 +65,13 @@ public class SchedulerTest extends AndroidTestCase { MockitoAnnotations.initMocks(this); mFakeClock = FakeClock.createWithCurrentTime(); mDataManager = new DvrDataManagerInMemoryImpl(getContext(), mFakeClock); + Mockito.when(mChannelDataManager.isDbLoadFinished()).thenReturn(true); mScheduler = new Scheduler(Looper.myLooper(), mDvrManager, mSessionManager, mDataManager, - mChannelDataManager, getContext(), mFakeClock, mMockAlarmManager); + mChannelDataManager, mInputManager, getContext(), mFakeClock, mMockAlarmManager); } public void testUpdate_none() throws Exception { + mScheduler.start(); mScheduler.update(); verifyZeroInteractions(mMockAlarmManager); } @@ -75,9 +80,15 @@ public class SchedulerTest extends AndroidTestCase { long now = mFakeClock.currentTimeMillis(); long startTime = now + TimeUnit.HOURS.toMillis(12); ScheduledRecording r = RecordingTestUtils - .createTestRecordingWithPeriod(CHANNEL_ID, startTime, + .createTestRecordingWithPeriod(INPUT_ID, CHANNEL_ID, startTime, startTime + TimeUnit.HOURS.toMillis(1)); mDataManager.addScheduledRecording(r); + mScheduler.start(); + 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).set( eq(AlarmManager.RTC_WAKEUP), @@ -89,7 +100,7 @@ public class SchedulerTest extends AndroidTestCase { long now = mFakeClock.currentTimeMillis(); long startTime = now + 3; ScheduledRecording r = RecordingTestUtils - .createTestRecordingWithPeriod(273, startTime, startTime + 100); + .createTestRecordingWithPeriod(INPUT_ID, CHANNEL_ID, startTime, startTime + 100); assertFalse(mScheduler.startsWithin(r, 2)); assertTrue(mScheduler.startsWithin(r, 3)); } |