aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/src/com/android/tv/TimeShiftManagerTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/src/com/android/tv/TimeShiftManagerTest.java')
-rw-r--r--tests/unit/src/com/android/tv/TimeShiftManagerTest.java100
1 files changed, 100 insertions, 0 deletions
diff --git a/tests/unit/src/com/android/tv/TimeShiftManagerTest.java b/tests/unit/src/com/android/tv/TimeShiftManagerTest.java
new file mode 100644
index 00000000..878d4293
--- /dev/null
+++ b/tests/unit/src/com/android/tv/TimeShiftManagerTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2015 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;
+
+import static com.android.tv.TimeShiftManager.TIME_SHIFT_ACTION_ID_FAST_FORWARD;
+import static com.android.tv.TimeShiftManager.TIME_SHIFT_ACTION_ID_JUMP_TO_NEXT;
+import static com.android.tv.TimeShiftManager.TIME_SHIFT_ACTION_ID_JUMP_TO_PREVIOUS;
+import static com.android.tv.TimeShiftManager.TIME_SHIFT_ACTION_ID_PAUSE;
+import static com.android.tv.TimeShiftManager.TIME_SHIFT_ACTION_ID_PLAY;
+import static com.android.tv.TimeShiftManager.TIME_SHIFT_ACTION_ID_REWIND;
+
+import android.test.suitebuilder.annotation.MediumTest;
+
+@MediumTest
+public class TimeShiftManagerTest extends BaseMainActivityTestCase {
+ private TimeShiftManager mTimeShiftManager;
+
+ public TimeShiftManagerTest() {
+ super(MainActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mTimeShiftManager = mActivity.getTimeShiftManager();
+ }
+
+ public void testDisableActions() {
+ enableAllActions(true);
+ assertActionState(true, true, true, true, true, true);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_PLAY, false);
+ assertActionState(false, true, true, true, true, true);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_PAUSE, false);
+ assertActionState(false, false, true, true, true, true);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_REWIND, false);
+ assertActionState(false, false, false, true, true, true);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_FAST_FORWARD, false);
+ assertActionState(false, false, false, false, true, true);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_JUMP_TO_PREVIOUS, false);
+ assertActionState(false, false, false, false, false, true);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_JUMP_TO_NEXT, false);
+ assertActionState(false, false, false, false, false, false);
+ }
+
+ public void testEnableActions() {
+ enableAllActions(false);
+ assertActionState(false, false, false, false, false, false);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_PLAY, true);
+ assertActionState(true, false, false, false, false, false);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_PAUSE, true);
+ assertActionState(true, true, false, false, false, false);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_REWIND, true);
+ assertActionState(true, true, true, false, false, false);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_FAST_FORWARD, true);
+ assertActionState(true, true, true, true, false, false);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_JUMP_TO_PREVIOUS, true);
+ assertActionState(true, true, true, true, true, false);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_JUMP_TO_NEXT, true);
+ assertActionState(true, true, true, true, true, true);
+ }
+
+ private void enableAllActions(boolean enabled) {
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_PLAY, enabled);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_PAUSE, enabled);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_REWIND, enabled);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_FAST_FORWARD, enabled);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_JUMP_TO_PREVIOUS, enabled);
+ mTimeShiftManager.enableAction(TIME_SHIFT_ACTION_ID_JUMP_TO_NEXT, enabled);
+ }
+
+ private void assertActionState(boolean playEnabled, boolean pauseEnabled, boolean rewindEnabled,
+ boolean fastForwardEnabled, boolean jumpToPreviousEnabled, boolean jumpToNextEnabled) {
+ assertEquals("Play Action", playEnabled,
+ mTimeShiftManager.isActionEnabled(TIME_SHIFT_ACTION_ID_PLAY));
+ assertEquals("Pause Action", pauseEnabled,
+ mTimeShiftManager.isActionEnabled(TIME_SHIFT_ACTION_ID_PAUSE));
+ assertEquals("Rewind Action", rewindEnabled,
+ mTimeShiftManager.isActionEnabled(TIME_SHIFT_ACTION_ID_REWIND));
+ assertEquals("Fast Forward Action", fastForwardEnabled,
+ mTimeShiftManager.isActionEnabled(TIME_SHIFT_ACTION_ID_FAST_FORWARD));
+ assertEquals("Jump To Previous Action", jumpToPreviousEnabled,
+ mTimeShiftManager.isActionEnabled(TIME_SHIFT_ACTION_ID_JUMP_TO_PREVIOUS));
+ assertEquals("Jump To Next Action", jumpToNextEnabled,
+ mTimeShiftManager.isActionEnabled(TIME_SHIFT_ACTION_ID_JUMP_TO_NEXT));
+ }
+}