aboutsummaryrefslogtreecommitdiff
path: root/tests/func/src/com/android/tv/tests/ui/PlayControlsRowViewTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/func/src/com/android/tv/tests/ui/PlayControlsRowViewTest.java')
-rw-r--r--tests/func/src/com/android/tv/tests/ui/PlayControlsRowViewTest.java127
1 files changed, 71 insertions, 56 deletions
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..7c982782 100644
--- a/tests/func/src/com/android/tv/tests/ui/PlayControlsRowViewTest.java
+++ b/tests/func/src/com/android/tv/tests/ui/PlayControlsRowViewTest.java
@@ -19,121 +19,136 @@ 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 static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
import android.support.test.filters.SmallTest;
import android.support.test.uiautomator.BySelector;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.Until;
import android.view.KeyEvent;
-
import com.android.tv.R;
import com.android.tv.testing.testinput.TvTestInputConstants;
+import com.android.tv.testing.uihelper.Constants;
import com.android.tv.testing.uihelper.DialogHelper;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
@SmallTest
-public class PlayControlsRowViewTest extends LiveChannelsTestCase {
- private static final String BUTTON_ID_PLAY_PAUSE = "com.android.tv:id/play_pause";
+@RunWith(JUnit4.class)
+public class PlayControlsRowViewTest {
+ private static final String BUTTON_ID_PLAY_PAUSE = Constants.TV_APP_PACKAGE + ":id/play_pause";
+ @Rule public final LiveChannelsTestController controller = new LiveChannelsTestController();
private BySelector mBySettingsSidePanel;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mLiveChannelsHelper.assertAppStarted();
- pressKeysForChannel(TvTestInputConstants.CH_2);
+ @Before
+ public void setUp() throws Exception {
+
+ controller.liveChannelsHelper.assertAppStarted();
+ controller.pressKeysForChannel(TvTestInputConstants.CH_2);
// Wait until KeypadChannelSwitchView closes.
- assertWaitForCondition(mDevice, Until.hasObject(CHANNEL_BANNER));
+ controller.assertWaitForCondition(Until.hasObject(CHANNEL_BANNER));
// Tune to a new channel to ensure that the channel is changed.
- mDevice.pressDPadUp();
- getInstrumentation().waitForIdleSync();
- mBySettingsSidePanel = mSidePanelHelper.bySidePanelTitled(
- R.string.side_panel_title_settings);
+ controller.pressDPadUp();
+ controller.waitForIdleSync();
+ mBySettingsSidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(R.string.side_panel_title_settings);
}
- /**
- * Test the normal case. The play/pause button should have focus initially.
- */
+ /** Test the normal case. The play/pause button should have focus initially. */
+ @Ignore("b/72154153")
+ @Test
public void testFocusedViewInNormalCase() {
- mMenuHelper.showMenu();
- mMenuHelper.assertNavigateToPlayControlsRow();
+ controller.menuHelper.showMenu();
+ controller.menuHelper.assertNavigateToPlayControlsRow();
assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE);
- mDevice.pressBack();
+ controller.pressBack();
}
/**
- * Tests the case when the forwarding action is disabled.
- * In this case, the button corresponding to the action is disabled, so play/pause button should
- * have the focus.
+ * Tests the case when the forwarding action is disabled. In this case, the button corresponding
+ * to the action is disabled, so play/pause button should have the focus.
*/
+ @Test
public void testFocusedViewWithDisabledActionForward() {
// Fast forward button
- mDevice.pressKeyCode(KeyEvent.KEYCODE_MEDIA_FAST_FORWARD);
- mMenuHelper.assertWaitForMenu();
+ controller.pressKeyCode(KeyEvent.KEYCODE_MEDIA_FAST_FORWARD);
+ controller.menuHelper.assertWaitForMenu();
assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE);
- mDevice.pressBack();
+ controller.pressBack();
// Next button
- mDevice.pressKeyCode(KeyEvent.KEYCODE_MEDIA_NEXT);
- mMenuHelper.assertWaitForMenu();
+ controller.pressKeyCode(KeyEvent.KEYCODE_MEDIA_NEXT);
+ controller.menuHelper.assertWaitForMenu();
assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE);
- mDevice.pressBack();
+ controller.pressBack();
}
+ @Test
public void testFocusedViewInMenu() {
- mMenuHelper.showMenu();
- mDevice.pressKeyCode(KeyEvent.KEYCODE_MEDIA_PLAY);
+ controller.menuHelper.showMenu();
+ controller.pressKeyCode(KeyEvent.KEYCODE_MEDIA_PLAY);
assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE);
- mMenuHelper.assertNavigateToRow(R.string.menu_title_channels);
- mDevice.pressKeyCode(KeyEvent.KEYCODE_MEDIA_NEXT);
+ controller.menuHelper.assertNavigateToRow(R.string.menu_title_channels);
+ controller.pressKeyCode(KeyEvent.KEYCODE_MEDIA_NEXT);
assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE);
}
+ @Ignore("b/72154153")
+ @Test
public void testKeepPausedWhileParentalControlChange() {
// Pause the playback.
- mDevice.pressKeyCode(KeyEvent.KEYCODE_MEDIA_PAUSE);
- mMenuHelper.assertWaitForMenu();
+ controller.pressKeyCode(KeyEvent.KEYCODE_MEDIA_PAUSE);
+ controller.menuHelper.assertWaitForMenu();
assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE);
// Show parental controls fragment.
- mMenuHelper.assertPressOptionsSettings();
- assertWaitForCondition(mDevice, Until.hasObject(mBySettingsSidePanel));
- mSidePanelHelper.assertNavigateToItem(R.string.settings_parental_controls);
- mDevice.pressDPadCenter();
- DialogHelper dialogHelper = new DialogHelper(mDevice, mTargetResources);
+ controller.menuHelper.assertPressOptionsSettings();
+ controller.assertWaitForCondition(Until.hasObject(mBySettingsSidePanel));
+ controller.sidePanelHelper.assertNavigateToItem(R.string.settings_parental_controls);
+ controller.pressDPadCenter();
+ DialogHelper dialogHelper =
+ new DialogHelper(controller.getUiDevice(), controller.getTargetResources());
dialogHelper.assertWaitForPinDialogOpen();
dialogHelper.enterPinCodes();
dialogHelper.assertWaitForPinDialogClose();
- BySelector bySidePanel = mSidePanelHelper.bySidePanelTitled(
- R.string.menu_parental_controls);
- assertWaitForCondition(mDevice, Until.hasObject(bySidePanel));
- mDevice.pressEnter();
- mDevice.pressEnter();
- mDevice.pressBack();
- mDevice.pressBack();
+ BySelector bySidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(R.string.menu_parental_controls);
+ controller.assertWaitForCondition(Until.hasObject(bySidePanel));
+ controller.pressEnter();
+ controller.pressEnter();
+ controller.pressBack();
+ controller.pressBack();
// Return to the main menu.
- mMenuHelper.assertWaitForMenu();
+ controller.menuHelper.assertWaitForMenu();
assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE);
}
+ // TODO("b/70727167"): fix tests
+ @Test
public void testKeepPausedAfterVisitingHome() {
// Pause the playback.
- mDevice.pressKeyCode(KeyEvent.KEYCODE_MEDIA_PAUSE);
- mMenuHelper.assertWaitForMenu();
+ controller.pressKeyCode(KeyEvent.KEYCODE_MEDIA_PAUSE);
+ controller.menuHelper.assertWaitForMenu();
assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE);
// Press HOME twice to visit the home screen and return to Live TV.
- mDevice.pressHome();
+ controller.pressHome();
// Wait until home screen is shown.
- mDevice.waitForIdle();
- mDevice.pressHome();
+ controller.waitForIdle();
+ controller.pressHome();
// Wait until TV is resumed.
- mDevice.waitForIdle();
+ controller.waitForIdle();
// Return to the main menu.
- mMenuHelper.assertWaitForMenu();
+ controller.menuHelper.assertWaitForMenu();
assertButtonHasFocus(BUTTON_ID_PLAY_PAUSE);
}
private void assertButtonHasFocus(String buttonId) {
- UiObject2 menu = mDevice.findObject(MENU);
+ UiObject2 menu = controller.getUiDevice().findObject(MENU);
UiObject2 focusedView = menu.findObject(FOCUSED_VIEW);
assertNotNull("Play controls row doesn't have a focused child.", focusedView);
UiObject2 focusedButtonGroup = focusedView.getParent();