aboutsummaryrefslogtreecommitdiff
path: root/tests/func/src/com/android/tv/tests/ui
diff options
context:
space:
mode:
Diffstat (limited to 'tests/func/src/com/android/tv/tests/ui')
-rw-r--r--tests/func/src/com/android/tv/tests/ui/ChannelBannerViewTest.java49
-rw-r--r--tests/func/src/com/android/tv/tests/ui/ChannelSourcesTest.java72
-rw-r--r--tests/func/src/com/android/tv/tests/ui/LiveChannelsAppTest.java139
-rw-r--r--tests/func/src/com/android/tv/tests/ui/LiveChannelsTestCase.java103
-rw-r--r--tests/func/src/com/android/tv/tests/ui/LiveChannelsTestController.java231
-rw-r--r--tests/func/src/com/android/tv/tests/ui/ParentalControlsTest.java172
-rw-r--r--tests/func/src/com/android/tv/tests/ui/PlayControlsRowViewTest.java127
-rw-r--r--tests/func/src/com/android/tv/tests/ui/ProgramGuideTest.java34
-rw-r--r--tests/func/src/com/android/tv/tests/ui/TimeoutTest.java52
-rw-r--r--tests/func/src/com/android/tv/tests/ui/dvr/DvrLibraryTest.java377
-rw-r--r--tests/func/src/com/android/tv/tests/ui/sidepanel/CustomizeChannelListFragmentTest.java112
11 files changed, 907 insertions, 561 deletions
diff --git a/tests/func/src/com/android/tv/tests/ui/ChannelBannerViewTest.java b/tests/func/src/com/android/tv/tests/ui/ChannelBannerViewTest.java
index d8a4aec1..600b52b6 100644
--- a/tests/func/src/com/android/tv/tests/ui/ChannelBannerViewTest.java
+++ b/tests/func/src/com/android/tv/tests/ui/ChannelBannerViewTest.java
@@ -16,37 +16,48 @@
package com.android.tv.tests.ui;
-import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertWaitForCondition;
-
-import android.support.test.filters.SmallTest;
+import android.support.test.filters.MediumTest;
import android.support.test.uiautomator.Until;
-
import com.android.tv.R;
import com.android.tv.testing.uihelper.Constants;
+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;
+
+/** Tests for {@link com.android.tv.ui.ChannelBannerView} */
+@MediumTest
+@RunWith(JUnit4.class)
+public class ChannelBannerViewTest {
+ @Rule public final LiveChannelsTestController controller = new LiveChannelsTestController();
-@SmallTest
-public class ChannelBannerViewTest extends LiveChannelsTestCase {
// Channel banner show duration with the grace period.
private long mShowDurationMillis;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mLiveChannelsHelper.assertAppStarted();
- mShowDurationMillis = mTargetResources.getInteger(R.integer.channel_banner_show_duration)
- + Constants.MAX_SHOW_DELAY_MILLIS;
+ @Before
+ public void setUp() throws Exception {
+ controller.liveChannelsHelper.assertAppStarted();
+ mShowDurationMillis =
+ controller.getTargetResources().getInteger(R.integer.channel_banner_show_duration)
+ + Constants.MAX_SHOW_DELAY_MILLIS;
}
+ @Ignore("b/73727914")
+ @Test
public void testChannelBannerAppearDisappear() {
- mDevice.pressDPadCenter();
- assertWaitForCondition(mDevice, Until.hasObject(Constants.CHANNEL_BANNER));
- assertWaitForCondition(mDevice, Until.gone(Constants.CHANNEL_BANNER), mShowDurationMillis);
+ controller.pressDPadCenter();
+ controller.assertWaitForCondition(Until.hasObject(Constants.CHANNEL_BANNER));
+ controller.assertWaitForCondition(
+ Until.gone(Constants.CHANNEL_BANNER), mShowDurationMillis);
}
+ @Test
public void testChannelBannerShownWhenTune() {
- mDevice.pressDPadDown();
- assertWaitForCondition(mDevice, Until.hasObject(Constants.CHANNEL_BANNER));
- mDevice.pressDPadUp();
- assertWaitForCondition(mDevice, Until.hasObject(Constants.CHANNEL_BANNER));
+ controller.pressDPadDown();
+ controller.assertWaitForCondition(Until.hasObject(Constants.CHANNEL_BANNER));
+ controller.pressDPadUp();
+ controller.assertWaitForCondition(Until.hasObject(Constants.CHANNEL_BANNER));
}
}
diff --git a/tests/func/src/com/android/tv/tests/ui/ChannelSourcesTest.java b/tests/func/src/com/android/tv/tests/ui/ChannelSourcesTest.java
index cfa5eda7..53e27f1b 100644
--- a/tests/func/src/com/android/tv/tests/ui/ChannelSourcesTest.java
+++ b/tests/func/src/com/android/tv/tests/ui/ChannelSourcesTest.java
@@ -15,56 +15,64 @@
*/
package com.android.tv.tests.ui;
-import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertWaitForCondition;
-
-import android.support.test.filters.LargeTest;
+import android.support.test.filters.MediumTest;
import android.support.test.uiautomator.BySelector;
import android.support.test.uiautomator.Until;
-
import com.android.tv.R;
import com.android.tv.testing.uihelper.ByResource;
-import com.android.tv.testing.uihelper.UiDeviceUtils;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
-/**
- * Tests for channel sources.
- */
-@LargeTest
-public class ChannelSourcesTest extends LiveChannelsTestCase {
+/** Tests for channel sources. */
+@MediumTest
+@RunWith(JUnit4.class)
+public class ChannelSourcesTest {
+ @Rule public final LiveChannelsTestController controller = new LiveChannelsTestController();
private BySelector mBySettingsSidePanel;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mBySettingsSidePanel = mSidePanelHelper.bySidePanelTitled(
- R.string.side_panel_title_settings);
+ @Before
+ public void before() throws Exception {
+ mBySettingsSidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(R.string.side_panel_title_settings);
}
- //TODO: create a cancelable test channel setup.
+ // TODO: create a cancelable test channel setup.
+ @Test
public void testSetup_cancel() {
- mLiveChannelsHelper.assertAppStarted();
- mMenuHelper.assertPressOptionsSettings();
- assertWaitForCondition(mDevice, Until.hasObject(mBySettingsSidePanel));
+ controller.liveChannelsHelper.assertAppStarted();
+ controller.menuHelper.assertPressOptionsSettings();
+ controller.assertWaitForCondition(Until.hasObject(mBySettingsSidePanel));
- mSidePanelHelper.assertNavigateToItem(R.string.settings_channel_source_item_setup);
- mDevice.pressDPadCenter();
+ controller.sidePanelHelper.assertNavigateToItem(
+ R.string.settings_channel_source_item_setup);
+ controller.pressDPadCenter();
- assertWaitForCondition(mDevice,
- Until.hasObject(ByResource.text(mTargetResources, R.string.setup_sources_text)));
- mDevice.pressBack();
+ controller.assertWaitForCondition(
+ Until.hasObject(
+ ByResource.text(
+ controller.getTargetResources(), R.string.setup_sources_text)));
+ controller.pressBack();
}
// SetupSourcesFragment should have no errors if side fragment item is clicked multiple times.
+ @Test
public void testSetupTwice_cancel() {
- mLiveChannelsHelper.assertAppStarted();
- mMenuHelper.assertPressOptionsSettings();
- assertWaitForCondition(mDevice, Until.hasObject(mBySettingsSidePanel));
+ controller.liveChannelsHelper.assertAppStarted();
+ controller.menuHelper.assertPressOptionsSettings();
+ controller.assertWaitForCondition(Until.hasObject(mBySettingsSidePanel));
- mSidePanelHelper.assertNavigateToItem(R.string.settings_channel_source_item_setup);
- UiDeviceUtils.pressDPadCenter(getInstrumentation(), 2);
+ controller.sidePanelHelper.assertNavigateToItem(
+ R.string.settings_channel_source_item_setup);
+ controller.pressDPadCenter(2);
- assertWaitForCondition(mDevice,
- Until.hasObject(ByResource.text(mTargetResources, R.string.setup_sources_text)));
- mDevice.pressBack();
+ controller.assertWaitForCondition(
+ Until.hasObject(
+ ByResource.text(
+ controller.getTargetResources(), R.string.setup_sources_text)));
+ controller.pressBack();
}
}
diff --git a/tests/func/src/com/android/tv/tests/ui/LiveChannelsAppTest.java b/tests/func/src/com/android/tv/tests/ui/LiveChannelsAppTest.java
index 48224123..1a5ceb45 100644
--- a/tests/func/src/com/android/tv/tests/ui/LiveChannelsAppTest.java
+++ b/tests/func/src/com/android/tv/tests/ui/LiveChannelsAppTest.java
@@ -16,103 +16,116 @@
package com.android.tv.tests.ui;
-import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertHas;
-import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertWaitForCondition;
-
-import android.support.test.filters.LargeTest;
+import android.support.test.filters.MediumTest;
import android.support.test.uiautomator.BySelector;
import android.support.test.uiautomator.Until;
-
import com.android.tv.R;
import com.android.tv.testing.testinput.ChannelStateData;
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;
+
+/** Basic tests for the LiveChannels app. */
+@MediumTest
+@RunWith(JUnit4.class)
+public class LiveChannelsAppTest {
+ @Rule public final LiveChannelsTestController controller = new LiveChannelsTestController();
-/**
- * Basic tests for the LiveChannels app.
- */
-@LargeTest
-public class LiveChannelsAppTest extends LiveChannelsTestCase {
private BySelector mBySettingsSidePanel;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mLiveChannelsHelper.assertAppStarted();
- pressKeysForChannel(TvTestInputConstants.CH_1_DEFAULT_DONT_MODIFY);
- getInstrumentation().waitForIdleSync();
- mBySettingsSidePanel = mSidePanelHelper.bySidePanelTitled(
- R.string.side_panel_title_settings);
+ @Before
+ public void setUp() throws Exception {
+ controller.liveChannelsHelper.assertAppStarted();
+ controller.pressKeysForChannel(TvTestInputConstants.CH_1_DEFAULT_DONT_MODIFY);
+ controller.waitForIdleSync();
+ mBySettingsSidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(R.string.side_panel_title_settings);
}
+ @Test
public void testSettingsCancel() {
- mMenuHelper.assertPressOptionsSettings();
- BySelector byChannelSourcesSidePanel = mSidePanelHelper
- .bySidePanelTitled(R.string.settings_channel_source_item_customize_channels);
- assertWaitForCondition(mDevice, Until.hasObject(byChannelSourcesSidePanel));
- mDevice.pressBack();
- assertWaitForCondition(mDevice, Until.gone(byChannelSourcesSidePanel));
- assertHas(mDevice, Constants.MENU, false);
+ controller.menuHelper.assertPressOptionsSettings();
+ BySelector byChannelSourcesSidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(
+ R.string.settings_channel_source_item_customize_channels);
+ controller.assertWaitForCondition(Until.hasObject(byChannelSourcesSidePanel));
+ controller.pressBack();
+ controller.assertWaitForCondition(Until.gone(byChannelSourcesSidePanel));
+ controller.assertHas(Constants.MENU, false);
}
+ @Test
public void testClosedCaptionsCancel() {
- mMenuHelper.assertPressOptionsClosedCaptions();
- BySelector byClosedCaptionSidePanel = mSidePanelHelper
- .bySidePanelTitled(R.string.side_panel_title_closed_caption);
- assertWaitForCondition(mDevice, Until.hasObject(byClosedCaptionSidePanel));
- mDevice.pressBack();
- assertWaitForCondition(mDevice, Until.gone(byClosedCaptionSidePanel));
- assertHas(mDevice, Constants.MENU, false);
+ controller.menuHelper.assertPressOptionsClosedCaptions();
+ BySelector byClosedCaptionSidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(
+ R.string.side_panel_title_closed_caption);
+ controller.assertWaitForCondition(Until.hasObject(byClosedCaptionSidePanel));
+ controller.pressBack();
+ controller.assertWaitForCondition(Until.gone(byClosedCaptionSidePanel));
+ controller.assertHas(Constants.MENU, false);
}
+ @Test
public void testDisplayModeCancel() {
ChannelStateData data = new ChannelStateData();
- data.mTvTrackInfos.add(com.android.tv.testing.Constants.SVGA_VIDEO_TRACK);
- data.mSelectedVideoTrackId = com.android.tv.testing.Constants.SVGA_VIDEO_TRACK
- .getId();
- updateThenTune(data, TvTestInputConstants.CH_2);
+ data.mTvTrackInfos.add(com.android.tv.testing.constants.Constants.SVGA_VIDEO_TRACK);
+ data.mSelectedVideoTrackId =
+ com.android.tv.testing.constants.Constants.SVGA_VIDEO_TRACK.getId();
+ controller.updateThenTune(data, TvTestInputConstants.CH_2);
- mMenuHelper.assertPressOptionsDisplayMode();
- BySelector byDisplayModeSidePanel = mSidePanelHelper
- .bySidePanelTitled(R.string.side_panel_title_display_mode);
- assertWaitForCondition(mDevice, Until.hasObject(byDisplayModeSidePanel));
- mDevice.pressBack();
- assertWaitForCondition(mDevice, Until.gone(byDisplayModeSidePanel));
- assertHas(mDevice, Constants.MENU, false);
+ controller.menuHelper.assertPressOptionsDisplayMode();
+ BySelector byDisplayModeSidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(
+ R.string.side_panel_title_display_mode);
+ controller.assertWaitForCondition(Until.hasObject(byDisplayModeSidePanel));
+ controller.pressBack();
+ controller.assertWaitForCondition(Until.gone(byDisplayModeSidePanel));
+ controller.assertHas(Constants.MENU, false);
}
+ @Test
public void testMenu() {
- mDevice.pressMenu();
+ controller.pressMenu();
- assertWaitForCondition(mDevice, Until.hasObject(Constants.MENU));
- assertHas(mDevice, mMenuHelper.getByChannels(), true);
+ controller.assertWaitForCondition(Until.hasObject(Constants.MENU));
+ controller.assertHas(controller.menuHelper.getByChannels(), true);
}
+ @Test
public void testMultiAudioCancel() {
ChannelStateData data = new ChannelStateData();
- data.mTvTrackInfos.add(com.android.tv.testing.Constants.GENERIC_AUDIO_TRACK);
- updateThenTune(data, TvTestInputConstants.CH_2);
+ data.mTvTrackInfos.add(com.android.tv.testing.constants.Constants.GENERIC_AUDIO_TRACK);
+ controller.updateThenTune(data, TvTestInputConstants.CH_2);
- mMenuHelper.assertPressOptionsMultiAudio();
- BySelector byMultiAudioSidePanel = mSidePanelHelper
- .bySidePanelTitled(R.string.side_panel_title_multi_audio);
- assertWaitForCondition(mDevice, Until.hasObject(byMultiAudioSidePanel));
- mDevice.pressBack();
- assertWaitForCondition(mDevice, Until.gone(byMultiAudioSidePanel));
- assertHas(mDevice, Constants.MENU, false);
+ controller.menuHelper.assertPressOptionsMultiAudio();
+ BySelector byMultiAudioSidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(R.string.side_panel_title_multi_audio);
+ controller.assertWaitForCondition(Until.hasObject(byMultiAudioSidePanel));
+ controller.pressBack();
+ controller.assertWaitForCondition(Until.gone(byMultiAudioSidePanel));
+ controller.assertHas(Constants.MENU, false);
}
+ @Ignore("b/72156196")
+ @Test
public void testPinCancel() {
- mMenuHelper.showMenu();
- mMenuHelper.assertPressOptionsSettings();
- assertWaitForCondition(mDevice, Until.hasObject(mBySettingsSidePanel));
- mSidePanelHelper.assertNavigateToItem(R.string.settings_parental_controls);
- mDevice.pressDPadCenter();
- DialogHelper dialogHelper = new DialogHelper(mDevice, mTargetResources);
+ controller.menuHelper.showMenu();
+ 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();
- mDevice.pressBack();
+ controller.pressBack();
dialogHelper.assertWaitForPinDialogClose();
- assertHas(mDevice, Constants.MENU, false);
+ controller.assertHas(Constants.MENU, false);
}
}
diff --git a/tests/func/src/com/android/tv/tests/ui/LiveChannelsTestCase.java b/tests/func/src/com/android/tv/tests/ui/LiveChannelsTestCase.java
deleted file mode 100644
index e306e6c6..00000000
--- a/tests/func/src/com/android/tv/tests/ui/LiveChannelsTestCase.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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.tests.ui;
-
-import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertWaitForCondition;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-
-import com.android.tv.testing.ChannelInfo;
-import com.android.tv.testing.testinput.ChannelStateData;
-import com.android.tv.testing.testinput.TestInputControlConnection;
-import com.android.tv.testing.testinput.TestInputControlUtils;
-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.SidePanelHelper;
-import com.android.tv.testing.uihelper.UiDeviceUtils;
-
-/**
- * Base test case for LiveChannel UI tests.
- */
-public abstract class LiveChannelsTestCase extends InstrumentationTestCase {
- protected final TestInputControlConnection mConnection = new TestInputControlConnection();
-
- protected UiDevice mDevice;
- protected Resources mTargetResources;
- protected MenuHelper mMenuHelper;
- protected SidePanelHelper mSidePanelHelper;
- protected LiveChannelsUiDeviceHelper mLiveChannelsHelper;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- Context context = getInstrumentation().getContext();
- context.bindService(TestInputControlUtils.createIntent(), mConnection,
- Context.BIND_AUTO_CREATE);
- mDevice = UiDevice.getInstance(getInstrumentation());
- mTargetResources = getInstrumentation().getTargetContext().getResources();
- mMenuHelper = new MenuHelper(mDevice, mTargetResources);
- mSidePanelHelper = new SidePanelHelper(mDevice, mTargetResources);
- mLiveChannelsHelper = new LiveChannelsUiDeviceHelper(mDevice, mTargetResources, context);
- }
-
- @Override
- protected void tearDown() throws Exception {
- if (mConnection.isBound()) {
- getInstrumentation().getContext().unbindService(mConnection);
- }
-
- // TODO: robustly handle left over pops from failed tests.
- // Clear any side panel, menu, ...
- // Scene container should not be checked here because pressing the BACK key in some scenes
- // might launch the home screen.
- if (mDevice.hasObject(Constants.SIDE_PANEL) || mDevice.hasObject(Constants.MENU) || mDevice
- .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();
- }
-
- /**
- * Send the keys for the channel number of {@code channel} and press the DPAD
- * center.
- *
- * <p>Usually this will tune to the given channel.
- */
- protected void pressKeysForChannel(ChannelInfo channel) {
- UiDeviceUtils.pressKeys(mDevice, channel.number);
- assertWaitForCondition(mDevice, Until.hasObject(Constants.KEYPAD_CHANNEL_SWITCH));
- mDevice.pressDPadCenter();
- }
-
- /**
- * Update the channel state to {@code data} then tune to that channel.
- *
- * @param data the state to update the channel with.
- * @param channel the channel to tune to
- */
- protected void updateThenTune(ChannelStateData data, ChannelInfo channel) {
- mConnection.updateChannelState(channel, data);
- pressKeysForChannel(channel);
- }
-}
diff --git a/tests/func/src/com/android/tv/tests/ui/LiveChannelsTestController.java b/tests/func/src/com/android/tv/tests/ui/LiveChannelsTestController.java
new file mode 100644
index 00000000..03d30ca4
--- /dev/null
+++ b/tests/func/src/com/android/tv/tests/ui/LiveChannelsTestController.java
@@ -0,0 +1,231 @@
+/*
+ * Copyright (C) 2018 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.tests.ui;
+
+import static junit.framework.Assert.assertTrue;
+
+import android.app.Instrumentation;
+import android.app.UiAutomation;
+import android.content.Context;
+import android.content.res.Resources;
+import android.os.Build;
+import android.os.SystemClock;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.uiautomator.BySelector;
+import android.support.test.uiautomator.Configurator;
+import android.support.test.uiautomator.SearchCondition;
+import android.support.test.uiautomator.UiDevice;
+import android.support.test.uiautomator.Until;
+import android.view.InputDevice;
+import android.view.KeyEvent;
+import com.android.tv.testing.data.ChannelInfo;
+import com.android.tv.testing.testinput.ChannelStateData;
+import com.android.tv.testing.testinput.TestInputControlConnection;
+import com.android.tv.testing.testinput.TestInputControlUtils;
+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.SidePanelHelper;
+import com.android.tv.testing.uihelper.UiDeviceAsserts;
+import com.android.tv.testing.uihelper.UiDeviceUtils;
+import org.junit.rules.ExternalResource;
+
+/** UIHelpers and TestInputController for LiveChannels. */
+public class LiveChannelsTestController extends ExternalResource {
+
+ private final TestInputControlConnection mConnection = new TestInputControlConnection();
+
+ public MenuHelper menuHelper;
+ public SidePanelHelper sidePanelHelper;
+ public LiveChannelsUiDeviceHelper liveChannelsHelper;
+
+ private UiDevice mDevice;
+ private Resources mTargetResources;
+ private Instrumentation mInstrumentation;
+
+ private void assertPressKeyUp(int keyCode, boolean sync) {
+ assertPressKey(KeyEvent.ACTION_UP, keyCode, sync);
+ }
+
+ private void assertPressKey(int action, int keyCode, boolean sync) {
+ long eventTime = SystemClock.uptimeMillis();
+ KeyEvent event =
+ new KeyEvent(
+ eventTime,
+ eventTime,
+ action,
+ keyCode,
+ 0,
+ 0,
+ -1,
+ 0,
+ 0,
+ InputDevice.SOURCE_KEYBOARD);
+ assertTrue("Failed to inject key up event:" + event, injectEvent(event, sync));
+ }
+
+ private UiAutomation getUiAutomation() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ int flags = Configurator.getInstance().getUiAutomationFlags();
+ return mInstrumentation.getUiAutomation(flags);
+ } else {
+ return mInstrumentation.getUiAutomation();
+ }
+ }
+
+ @Override
+ protected void before() throws Exception {
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ Context context = mInstrumentation.getContext();
+ context.bindService(
+ TestInputControlUtils.createIntent(), mConnection, Context.BIND_AUTO_CREATE);
+ mDevice = UiDevice.getInstance(mInstrumentation);
+ mTargetResources = mInstrumentation.getTargetContext().getResources();
+ menuHelper = new MenuHelper(mDevice, mTargetResources);
+ sidePanelHelper = new SidePanelHelper(mDevice, mTargetResources);
+ liveChannelsHelper = new LiveChannelsUiDeviceHelper(mDevice, mTargetResources, context);
+ }
+
+ @Override
+ protected void after() {
+ if (mConnection.isBound()) {
+ mInstrumentation.getContext().unbindService(mConnection);
+ }
+
+ // TODO: robustly handle left over pops from failed tests.
+ // Clear any side panel, menu, ...
+ // Scene container should not be checked here because pressing the BACK key in some scenes
+ // might launch the home screen.
+ if (mDevice.hasObject(Constants.SIDE_PANEL)
+ || mDevice.hasObject(Constants.MENU)
+ || mDevice.hasObject(Constants.PROGRAM_GUIDE)) {
+ mDevice.pressBack();
+ }
+ // To destroy the activity to make sure next test case's activity launch check works well.
+ mDevice.pressBack();
+ }
+
+ /**
+ * Update the channel state to {@code data} then tune to that channel.
+ *
+ * @param data the state to update the channel with.
+ * @param channel the channel to tune to
+ */
+ protected void updateThenTune(ChannelStateData data, ChannelInfo channel) {
+ mConnection.updateChannelState(channel, data);
+ pressKeysForChannel(channel);
+ }
+
+ /**
+ * Send the keys for the channel number of {@code channel} and press the DPAD center.
+ *
+ * <p>Usually this will tune to the given channel.
+ */
+ public void pressKeysForChannel(ChannelInfo channel) {
+ UiDeviceUtils.pressKeys(mDevice, channel.number);
+ UiDeviceAsserts.assertWaitForCondition(
+ mDevice, Until.hasObject(Constants.KEYPAD_CHANNEL_SWITCH));
+ mDevice.pressDPadCenter();
+ }
+
+ public void assertHas(BySelector bySelector, boolean expected) {
+ UiDeviceAsserts.assertHas(mDevice, bySelector, expected);
+ }
+
+ public void assertWaitForCondition(SearchCondition<Boolean> booleanSearchCondition) {
+ UiDeviceAsserts.assertWaitForCondition(mDevice, booleanSearchCondition);
+ }
+
+ public void assertWaitForCondition(SearchCondition<Boolean> gone, long timeout) {
+ UiDeviceAsserts.assertWaitForCondition(mDevice, gone, timeout);
+ }
+
+ public void assertWaitUntilFocused(BySelector bySelector) {
+ UiDeviceAsserts.assertWaitUntilFocused(mDevice, bySelector);
+ }
+
+ public Resources getTargetResources() {
+ return mTargetResources;
+ }
+
+ public UiDevice getUiDevice() {
+ return mDevice;
+ }
+
+ public boolean injectEvent(KeyEvent event, boolean sync) {
+ return getUiAutomation().injectInputEvent(event, sync);
+ }
+
+ public void pressBack() {
+ mDevice.pressBack();
+ }
+
+ public void pressDPadCenter() {
+ pressDPadCenter(1);
+ }
+
+ public void pressDPadCenter(int repeat) {
+ UiDevice.getInstance(mInstrumentation).waitForIdle();
+ for (int i = 0; i < repeat; ++i) {
+ assertPressKey(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_CENTER, false);
+ if (i < repeat - 1) {
+ assertPressKeyUp(KeyEvent.KEYCODE_DPAD_CENTER, false);
+ }
+ }
+ // Send last key event synchronously.
+ assertPressKeyUp(KeyEvent.KEYCODE_DPAD_CENTER, true);
+ }
+
+ public void pressDPadDown() {
+ mDevice.pressDPadDown();
+ }
+
+ public void pressDPadLeft() {
+ mDevice.pressDPadLeft();
+ }
+
+ public void pressDPadRight() {
+ mDevice.pressDPadRight();
+ }
+
+ public void pressDPadUp() {
+ mDevice.pressDPadUp();
+ }
+
+ public void pressEnter() {
+ mDevice.pressEnter();
+ }
+
+ public void pressHome() {
+ mDevice.pressHome();
+ }
+
+ public void pressKeyCode(int keyCode) {
+ mDevice.pressKeyCode(keyCode);
+ }
+
+ public void pressMenu() {
+ mDevice.pressMenu();
+ }
+
+ public void waitForIdle() {
+ mDevice.waitForIdle();
+ }
+
+ public void waitForIdleSync() {
+ mInstrumentation.waitForIdleSync();
+ }
+}
diff --git a/tests/func/src/com/android/tv/tests/ui/ParentalControlsTest.java b/tests/func/src/com/android/tv/tests/ui/ParentalControlsTest.java
index 93d14bde..ee039d7c 100644
--- a/tests/func/src/com/android/tv/tests/ui/ParentalControlsTest.java
+++ b/tests/func/src/com/android/tv/tests/ui/ParentalControlsTest.java
@@ -16,139 +16,169 @@
package com.android.tv.tests.ui;
-import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertWaitForCondition;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
-import android.support.test.filters.SmallTest;
+import android.support.test.filters.MediumTest;
import android.support.test.uiautomator.BySelector;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.Until;
-
import com.android.tv.R;
import com.android.tv.testing.uihelper.ByResource;
import com.android.tv.testing.uihelper.DialogHelper;
+import org.junit.After;
+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 ParentalControlsTest extends LiveChannelsTestCase {
-
+/** Tests for {@link com.android.tv.ui.sidepanel.parentalcontrols.ParentalControlsFragment} */
+@MediumTest
+@RunWith(JUnit4.class)
+public class ParentalControlsTest {
+ @Rule public final LiveChannelsTestController controller = new LiveChannelsTestController();
private BySelector mBySettingsSidePanel;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mLiveChannelsHelper.assertAppStarted();
- mBySettingsSidePanel = mSidePanelHelper.bySidePanelTitled(
- R.string.side_panel_title_settings);
- prepareParentalControl();
+ @Before
+ public void setUp() throws Exception {
+
+ controller.liveChannelsHelper.assertAppStarted();
+ mBySettingsSidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(R.string.side_panel_title_settings);
+ // TODO(b/72154681): prepareParentalControl();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
switchParentalControl(R.string.option_toggle_parental_controls_on);
- super.tearDown();
}
+ @Test
+ public void placeHolder() {
+ // there must be at least one test.
+ }
+
+ @Ignore("b/72154681")
+ @Test
public void testRatingDependentSelect() {
// Show ratings fragment.
- BySelector bySidePanel = mSidePanelHelper.bySidePanelTitled(
- R.string.option_program_restrictions);
- assertWaitForCondition(mDevice, Until.hasObject(bySidePanel));
- mSidePanelHelper.assertNavigateToItem(R.string.option_ratings);
- mDevice.pressDPadCenter();
+ BySelector bySidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(R.string.option_program_restrictions);
+ controller.assertWaitForCondition(Until.hasObject(bySidePanel));
+ controller.sidePanelHelper.assertNavigateToItem(R.string.option_ratings);
+ controller.pressDPadCenter();
// Block rating 6 and rating 12. Check if dependent select works well.
- bySidePanel = mSidePanelHelper.bySidePanelTitled(R.string.option_ratings);
- assertWaitForCondition(mDevice, Until.hasObject(bySidePanel));
+ bySidePanel = controller.sidePanelHelper.bySidePanelTitled(R.string.option_ratings);
+ controller.assertWaitForCondition(Until.hasObject(bySidePanel));
// Test on blocking and unblocking Japanese rating.
int blockAge = 6;
int unBlockAge = 12;
int maxAge = 20;
int minAge = 4;
for (int age = minAge; age <= maxAge; age++) {
- UiObject2 ratingCheckBox = mSidePanelHelper.assertNavigateToItem(String.valueOf(age))
- .findObject(ByResource.id(mTargetResources, R.id.check_box));
+ UiObject2 ratingCheckBox =
+ controller
+ .sidePanelHelper
+ .assertNavigateToItem(String.valueOf(age))
+ .findObject(
+ ByResource.id(controller.getTargetResources(), R.id.check_box));
if (ratingCheckBox.isChecked()) {
- mDevice.pressDPadCenter();
+ controller.pressDPadCenter();
}
}
- mSidePanelHelper.assertNavigateToItem(String.valueOf(blockAge));
- mDevice.pressDPadCenter();
+ controller.sidePanelHelper.assertNavigateToItem(String.valueOf(blockAge));
+ controller.pressDPadCenter();
assertRatingViewIsChecked(minAge, maxAge, blockAge, true);
- mSidePanelHelper.assertNavigateToItem(String.valueOf(unBlockAge));
- mDevice.pressDPadCenter();
+ controller.sidePanelHelper.assertNavigateToItem(String.valueOf(unBlockAge));
+ controller.pressDPadCenter();
assertRatingViewIsChecked(minAge, maxAge, unBlockAge, false);
- mDevice.pressBack();
- mDevice.pressBack();
- getInstrumentation().waitForIdleSync();
+ controller.pressBack();
+ controller.pressBack();
+ controller.waitForIdleSync();
}
- private void assertRatingViewIsChecked(int minAge, int maxAge, int selectedAge,
- boolean expectedValue) {
+ private void assertRatingViewIsChecked(
+ int minAge, int maxAge, int selectedAge, boolean expectedValue) {
for (int age = minAge; age <= maxAge; age++) {
- UiObject2 ratingCheckBox = mSidePanelHelper.assertNavigateToItem(String.valueOf(age))
- .findObject(ByResource.id(mTargetResources, R.id.check_box));
+ UiObject2 ratingCheckBox =
+ controller
+ .sidePanelHelper
+ .assertNavigateToItem(String.valueOf(age))
+ .findObject(
+ ByResource.id(controller.getTargetResources(), R.id.check_box));
if (age < selectedAge) {
assertTrue("The lower rating age should be unblocked", !ratingCheckBox.isChecked());
} else if (age > selectedAge) {
assertTrue("The higher rating age should be blocked", ratingCheckBox.isChecked());
} else {
- assertEquals("The rating for age " + selectedAge + " isBlocked ", expectedValue,
+ assertEquals(
+ "The rating for age " + selectedAge + " isBlocked ",
+ expectedValue,
ratingCheckBox.isChecked());
}
}
}
/**
- * Prepare the need for testRatingDependentSelect.
- * 1. Turn on parental control if it's off.
- * 2. Make sure Japan rating system is selected.
+ * Prepare the need for testRatingDependentSelect. 1. Turn on parental control if it's off. 2.
+ * Make sure Japan rating system is selected.
*/
private void prepareParentalControl() {
showParentalControl();
switchParentalControl(R.string.option_toggle_parental_controls_off);
// Show all rating systems.
- mSidePanelHelper.assertNavigateToItem(R.string.option_program_restrictions);
- mDevice.pressDPadCenter();
- BySelector bySidePanel = mSidePanelHelper.bySidePanelTitled(
- R.string.option_program_restrictions);
- assertWaitForCondition(mDevice, Until.hasObject(bySidePanel));
- mSidePanelHelper.assertNavigateToItem(R.string.option_country_rating_systems);
- mDevice.pressDPadCenter();
- bySidePanel = mSidePanelHelper.bySidePanelTitled(R.string.option_country_rating_systems);
- assertWaitForCondition(mDevice,Until.hasObject(bySidePanel));
- mSidePanelHelper.assertNavigateToItem(R.string.option_see_all_rating_systems);
- mDevice.pressDPadCenter();
+ controller.sidePanelHelper.assertNavigateToItem(R.string.option_program_restrictions);
+ controller.pressDPadCenter();
+ BySelector bySidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(R.string.option_program_restrictions);
+ controller.assertWaitForCondition(Until.hasObject(bySidePanel));
+ controller.sidePanelHelper.assertNavigateToItem(R.string.option_country_rating_systems);
+ controller.pressDPadCenter();
+ bySidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(
+ R.string.option_country_rating_systems);
+ controller.assertWaitForCondition(Until.hasObject(bySidePanel));
+ controller.sidePanelHelper.assertNavigateToItem(R.string.option_see_all_rating_systems);
+ controller.pressDPadCenter();
// Make sure Japan rating system is selected.
- UiObject2 ratingSystemCheckBox = mSidePanelHelper.assertNavigateToItem("Japan")
- .findObject(ByResource.id(mTargetResources, R.id.check_box));
+ UiObject2 ratingSystemCheckBox =
+ controller
+ .sidePanelHelper
+ .assertNavigateToItem("Japan")
+ .findObject(ByResource.id(controller.getTargetResources(), R.id.check_box));
if (!ratingSystemCheckBox.isChecked()) {
- mDevice.pressDPadCenter();
- getInstrumentation().waitForIdleSync();
+ controller.pressDPadCenter();
+ controller.waitForIdleSync();
}
- mDevice.pressBack();
+ controller.pressBack();
}
private void switchParentalControl(int oppositeStateResId) {
- BySelector bySidePanel = mSidePanelHelper.byViewText(oppositeStateResId);
- if (mDevice.hasObject(bySidePanel)) {
- mSidePanelHelper.assertNavigateToItem(oppositeStateResId);
- mDevice.pressDPadCenter();
- getInstrumentation().waitForIdleSync();
+ BySelector bySidePanel = controller.sidePanelHelper.byViewText(oppositeStateResId);
+ if (controller.getUiDevice().hasObject(bySidePanel)) {
+ controller.sidePanelHelper.assertNavigateToItem(oppositeStateResId);
+ controller.pressDPadCenter();
+ controller.waitForIdleSync();
}
}
private void showParentalControl() {
// Show menu and select parental controls.
- mMenuHelper.showMenu();
- mMenuHelper.assertPressOptionsSettings();
- assertWaitForCondition(mDevice, Until.hasObject(mBySettingsSidePanel));
- mSidePanelHelper.assertNavigateToItem(R.string.settings_parental_controls);
- mDevice.pressDPadCenter();
+ controller.menuHelper.showMenu();
+ controller.menuHelper.assertPressOptionsSettings();
+ controller.assertWaitForCondition(Until.hasObject(mBySettingsSidePanel));
+ controller.sidePanelHelper.assertNavigateToItem(R.string.settings_parental_controls);
+ controller.pressDPadCenter();
// Enter pin code.
- DialogHelper dialogHelper = new DialogHelper(mDevice, mTargetResources);
+ 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));
+ BySelector bySidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(R.string.menu_parental_controls);
+ controller.assertWaitForCondition(Until.hasObject(bySidePanel));
}
}
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();
diff --git a/tests/func/src/com/android/tv/tests/ui/ProgramGuideTest.java b/tests/func/src/com/android/tv/tests/ui/ProgramGuideTest.java
index 06c76b3b..4adf448a 100644
--- a/tests/func/src/com/android/tv/tests/ui/ProgramGuideTest.java
+++ b/tests/func/src/com/android/tv/tests/ui/ProgramGuideTest.java
@@ -15,28 +15,28 @@
*/
package com.android.tv.tests.ui;
-import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertHas;
-import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertWaitForCondition;
-
-import android.support.test.filters.LargeTest;
+import android.support.test.filters.MediumTest;
import android.support.test.uiautomator.Until;
-
import com.android.tv.guide.ProgramGuide;
import com.android.tv.testing.uihelper.Constants;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
-/**
- * Tests for {@link ProgramGuide}.
- */
-@LargeTest
-public class ProgramGuideTest extends LiveChannelsTestCase {
+/** Tests for {@link ProgramGuide}. */
+@MediumTest
+@RunWith(JUnit4.class)
+public class ProgramGuideTest {
+ @Rule public final LiveChannelsTestController controller = new LiveChannelsTestController();
+ @Test
public void testCancel() {
- mLiveChannelsHelper.assertAppStarted();
- mMenuHelper.assertPressProgramGuide();
- assertWaitForCondition(mDevice,
- Until.hasObject(Constants.PROGRAM_GUIDE));
- mDevice.pressBack();
- assertWaitForCondition(mDevice, Until.gone(Constants.PROGRAM_GUIDE));
- assertHas(mDevice, Constants.MENU, false);
+ controller.liveChannelsHelper.assertAppStarted();
+ controller.menuHelper.assertPressProgramGuide();
+ controller.assertWaitForCondition(Until.hasObject(Constants.PROGRAM_GUIDE));
+ controller.pressBack();
+ controller.assertWaitForCondition(Until.gone(Constants.PROGRAM_GUIDE));
+ controller.assertHas(Constants.MENU, false);
}
}
diff --git a/tests/func/src/com/android/tv/tests/ui/TimeoutTest.java b/tests/func/src/com/android/tv/tests/ui/TimeoutTest.java
index 9bf2ac50..4b6befe4 100644
--- a/tests/func/src/com/android/tv/tests/ui/TimeoutTest.java
+++ b/tests/func/src/com/android/tv/tests/ui/TimeoutTest.java
@@ -15,40 +15,54 @@
*/
package com.android.tv.tests.ui;
-import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertHas;
-import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertWaitForCondition;
-
import android.support.test.filters.LargeTest;
import android.support.test.uiautomator.Until;
-
import com.android.tv.R;
import com.android.tv.testing.uihelper.Constants;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
/**
* Test timeout events like the menu despairing after no input.
- * <p>
- * <b>WARNING</b> some of these timeouts are 60 seconds. These tests will take a long time
+ *
+ * <p><b>WARNING</b> some of these timeouts are 60 seconds. These tests will take a long time
* complete.
*/
@LargeTest
-public class TimeoutTest extends LiveChannelsTestCase {
+@RunWith(JUnit4.class)
+public class TimeoutTest {
+
+ @Rule public final LiveChannelsTestController controller = new LiveChannelsTestController();
+
+ @Test
+ public void placeholder() {
+ // There must be at least one test
+ }
+ @Ignore("b/73727914")
+ @Test
public void testMenu() {
- mLiveChannelsHelper.assertAppStarted();
- mDevice.pressMenu();
+ controller.liveChannelsHelper.assertAppStarted();
+ controller.pressMenu();
- assertWaitForCondition(mDevice, Until.hasObject(Constants.MENU));
- assertWaitForCondition(mDevice, Until.gone(Constants.MENU),
- mTargetResources.getInteger(R.integer.menu_show_duration));
+ controller.assertWaitForCondition(Until.hasObject(Constants.MENU));
+ controller.assertWaitForCondition(
+ Until.gone(Constants.MENU),
+ controller.getTargetResources().getInteger(R.integer.menu_show_duration));
}
+ @Ignore("b/73727914")
+ @Test
public void testProgramGuide() {
- mLiveChannelsHelper.assertAppStarted();
- mMenuHelper.assertPressProgramGuide();
- assertWaitForCondition(mDevice,
- Until.hasObject(Constants.PROGRAM_GUIDE));
- assertWaitForCondition(mDevice, Until.gone(Constants.PROGRAM_GUIDE),
- mTargetResources.getInteger(R.integer.program_guide_show_duration));
- assertHas(mDevice, Constants.MENU, false);
+ controller.liveChannelsHelper.assertAppStarted();
+ controller.menuHelper.assertPressProgramGuide();
+ controller.assertWaitForCondition(Until.hasObject(Constants.PROGRAM_GUIDE));
+ controller.assertWaitForCondition(
+ Until.gone(Constants.PROGRAM_GUIDE),
+ controller.getTargetResources().getInteger(R.integer.program_guide_show_duration));
+ controller.assertHas(Constants.MENU, false);
}
}
diff --git a/tests/func/src/com/android/tv/tests/ui/dvr/DvrLibraryTest.java b/tests/func/src/com/android/tv/tests/ui/dvr/DvrLibraryTest.java
index d88e67ad..d0ebed91 100644
--- a/tests/func/src/com/android/tv/tests/ui/dvr/DvrLibraryTest.java
+++ b/tests/func/src/com/android/tv/tests/ui/dvr/DvrLibraryTest.java
@@ -16,8 +16,6 @@
package com.android.tv.tests.ui.dvr;
-import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertHas;
-import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertWaitForCondition;
import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertWaitUntilFocused;
import android.os.Build;
@@ -25,195 +23,302 @@ import android.support.test.filters.MediumTest;
import android.support.test.filters.SdkSuppress;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.Until;
-
import com.android.tv.R;
import com.android.tv.testing.uihelper.ByResource;
import com.android.tv.testing.uihelper.Constants;
-import com.android.tv.tests.ui.LiveChannelsTestCase;
-
+import com.android.tv.tests.ui.LiveChannelsTestController;
import java.util.regex.Pattern;
+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;
+/** Test the DVR library UI */
@MediumTest
+@RunWith(JUnit4.class)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.N)
-public class DvrLibraryTest extends LiveChannelsTestCase {
+public class DvrLibraryTest {
private static final String PROGRAM_NAME_PREFIX = "Title(";
+ @Rule public final LiveChannelsTestController controller = new LiveChannelsTestController();
+
private BySelector mRecentRow;
private BySelector mScheduledRow;
private BySelector mSeriesRow;
private BySelector mFullScheduleCard;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mRecentRow = By.hasDescendant(ByResource.text(mTargetResources, R.string.dvr_main_recent));
- mScheduledRow = By.hasDescendant(
- ByResource.text(mTargetResources, R.string.dvr_main_scheduled));
- mSeriesRow = By.hasDescendant(ByResource.text(mTargetResources, R.string.dvr_main_series));
- mFullScheduleCard = By.focusable(true).hasDescendant(
- ByResource.text(mTargetResources, R.string.dvr_full_schedule_card_view_title));
- mLiveChannelsHelper.assertAppStarted();
+ @Before
+ public void setUp() throws Exception {
+
+ mRecentRow =
+ By.hasDescendant(
+ ByResource.text(controller.getTargetResources(), R.string.dvr_main_recent));
+ mScheduledRow =
+ By.hasDescendant(
+ ByResource.text(
+ controller.getTargetResources(), R.string.dvr_main_scheduled));
+ mSeriesRow =
+ By.hasDescendant(
+ ByResource.text(controller.getTargetResources(), R.string.dvr_main_series));
+ mFullScheduleCard =
+ By.focusable(true)
+ .hasDescendant(
+ ByResource.text(
+ controller.getTargetResources(),
+ R.string.dvr_full_schedule_card_view_title));
+ controller.liveChannelsHelper.assertAppStarted();
}
+ @Test
+ public void placeholder() {
+ // TODO(b/72153742): three must be at least one test
+ }
+
+ @Ignore("b/72153742")
+ @Test
public void testCancel() {
- mMenuHelper.assertPressDvrLibrary();
- assertWaitForCondition(mDevice, Until.hasObject(Constants.DVR_LIBRARY));
- mDevice.pressBack();
- assertWaitForCondition(mDevice, Until.gone(Constants.DVR_LIBRARY));
- assertHas(mDevice, Constants.MENU, false);
+ controller.menuHelper.assertPressDvrLibrary();
+ controller.assertWaitForCondition(Until.hasObject(Constants.DVR_LIBRARY));
+ controller.pressBack();
+ controller.assertWaitForCondition(Until.gone(Constants.DVR_LIBRARY));
+ controller.assertHas(Constants.MENU, false);
}
+ @Ignore("b/72153742")
+ @Test
public void testEmptyLibrary() {
- mMenuHelper.assertPressDvrLibrary();
- assertWaitForCondition(mDevice, Until.hasObject(Constants.DVR_LIBRARY));
+ controller.menuHelper.assertPressDvrLibrary();
+ controller.assertWaitForCondition(Until.hasObject(Constants.DVR_LIBRARY));
// DVR Library is empty, only Scheduled row and Full schedule card should be displayed.
- assertHas(mDevice, mRecentRow, false);
- assertHas(mDevice, mScheduledRow, true);
- assertHas(mDevice, mSeriesRow, false);
+ controller.assertHas(mRecentRow, false);
+ controller.assertHas(mScheduledRow, true);
+ controller.assertHas(mSeriesRow, false);
- mDevice.pressDPadCenter();
- assertWaitUntilFocused(mDevice, mFullScheduleCard);
- mDevice.pressDPadCenter();
- assertWaitForCondition(mDevice, Until.gone(Constants.DVR_LIBRARY));
+ controller.pressDPadCenter();
+ assertWaitUntilFocused(controller.getUiDevice(), mFullScheduleCard);
+ controller.pressDPadCenter();
+ controller.assertWaitForCondition(Until.gone(Constants.DVR_LIBRARY));
// Empty schedules screen should be shown.
- assertHas(mDevice, Constants.DVR_SCHEDULES, true);
- assertHas(mDevice, ByResource.text(mTargetResources, R.string.dvr_schedules_empty_state),
+ controller.assertHas(Constants.DVR_SCHEDULES, true);
+ controller.assertHas(
+ ByResource.text(
+ controller.getTargetResources(), R.string.dvr_schedules_empty_state),
true);
// Close the DVR library.
- mDevice.pressBack();
- assertWaitForCondition(mDevice, Until.hasObject(Constants.DVR_LIBRARY));
- mDevice.pressBack();
- assertWaitForCondition(mDevice, Until.gone(Constants.DVR_LIBRARY));
+ controller.pressBack();
+ controller.assertWaitForCondition(Until.hasObject(Constants.DVR_LIBRARY));
+ controller.pressBack();
+ controller.assertWaitForCondition(Until.gone(Constants.DVR_LIBRARY));
}
+ @Ignore("b/72153742")
+ @Test
public void testScheduleRecordings() {
- BySelector newScheduleCard = By.focusable(true).hasDescendant(
- By.textStartsWith(PROGRAM_NAME_PREFIX)).hasDescendant(By.textEndsWith("today"));
- BySelector seriesCardWithOneSchedule = By.focusable(true).hasDescendant(
- By.textStartsWith(PROGRAM_NAME_PREFIX)).hasDescendant(By.text(mTargetResources
- .getQuantityString(R.plurals.dvr_count_scheduled_recordings, 1, 1)));
- BySelector seriesCardWithOneRecordedProgram = By.focusable(true).hasDescendant(
- By.textStartsWith(PROGRAM_NAME_PREFIX)).hasDescendant(By.text(mTargetResources
- .getQuantityString(R.plurals.dvr_count_new_recordings, 1, 1)));
- Pattern watchButton = Pattern.compile("^" + mTargetResources
- .getString(R.string.dvr_detail_watch).toUpperCase() + "\n.*$");
-
- mMenuHelper.showMenu();
- mMenuHelper.assertNavigateToPlayControlsRow();
- mDevice.pressDPadRight();
- mDevice.pressDPadCenter();
- assertWaitForCondition(mDevice, Until.hasObject(
- ByResource.text(mTargetResources, R.string.dvr_action_record_episode)));
- mDevice.pressDPadCenter();
- assertWaitForCondition(mDevice, Until.gone(
- ByResource.text(mTargetResources, R.string.dvr_action_record_episode)));
-
- mMenuHelper.assertPressDvrLibrary();
- assertWaitForCondition(mDevice, Until.hasObject(Constants.DVR_LIBRARY));
+ BySelector newScheduleCard =
+ By.focusable(true)
+ .hasDescendant(By.textStartsWith(PROGRAM_NAME_PREFIX))
+ .hasDescendant(By.textEndsWith("today"));
+ BySelector seriesCardWithOneSchedule =
+ By.focusable(true)
+ .hasDescendant(By.textStartsWith(PROGRAM_NAME_PREFIX))
+ .hasDescendant(
+ By.text(
+ controller
+ .getTargetResources()
+ .getQuantityString(
+ R.plurals.dvr_count_scheduled_recordings,
+ 1,
+ 1)));
+ BySelector seriesCardWithOneRecordedProgram =
+ By.focusable(true)
+ .hasDescendant(By.textStartsWith(PROGRAM_NAME_PREFIX))
+ .hasDescendant(
+ By.text(
+ controller
+ .getTargetResources()
+ .getQuantityString(
+ R.plurals.dvr_count_new_recordings, 1, 1)));
+ Pattern watchButton =
+ Pattern.compile(
+ "^"
+ + controller
+ .getTargetResources()
+ .getString(R.string.dvr_detail_watch)
+ .toUpperCase()
+ + "\n.*$");
+
+ controller.menuHelper.showMenu();
+ controller.menuHelper.assertNavigateToPlayControlsRow();
+ controller.pressDPadRight();
+ controller.pressDPadCenter();
+ controller.assertWaitForCondition(
+ Until.hasObject(
+ ByResource.text(
+ controller.getTargetResources(),
+ R.string.dvr_action_record_episode)));
+ controller.pressDPadCenter();
+ controller.assertWaitForCondition(
+ Until.gone(
+ ByResource.text(
+ controller.getTargetResources(),
+ R.string.dvr_action_record_episode)));
+
+ controller.menuHelper.assertPressDvrLibrary();
+ controller.assertWaitForCondition(Until.hasObject(Constants.DVR_LIBRARY));
// Schedule should be automatically added to the series.
- assertHas(mDevice, mRecentRow, false);
- assertHas(mDevice, mScheduledRow, true);
- assertHas(mDevice, mSeriesRow, true);
- String programName = mDevice.findObject(By.textStartsWith(PROGRAM_NAME_PREFIX)).getText();
+ controller.assertHas(mRecentRow, false);
+ controller.assertHas(mScheduledRow, true);
+ controller.assertHas(mSeriesRow, true);
+ String programName =
+ controller
+ .getUiDevice()
+ .findObject(By.textStartsWith(PROGRAM_NAME_PREFIX))
+ .getText();
// Move to scheduled row, there should be one new schedule and one full schedule card.
- mDevice.pressDPadRight();
- assertWaitUntilFocused(mDevice, newScheduleCard);
- mDevice.pressDPadRight();
- assertWaitUntilFocused(mDevice, mFullScheduleCard);
+ controller.pressDPadRight();
+ controller.assertWaitUntilFocused(newScheduleCard);
+ controller.pressDPadRight();
+ controller.assertWaitUntilFocused(mFullScheduleCard);
// Enters the full schedule, there should be one schedule in the full schedule.
- mDevice.pressDPadCenter();
- assertWaitForCondition(mDevice, Until.gone(Constants.DVR_LIBRARY));
- assertHas(mDevice, Constants.DVR_SCHEDULES, true);
- assertHas(mDevice, ByResource.text(mTargetResources, R.string.dvr_schedules_empty_state),
+ controller.pressDPadCenter();
+ controller.assertWaitForCondition(Until.gone(Constants.DVR_LIBRARY));
+ controller.assertHas(Constants.DVR_SCHEDULES, true);
+ controller.assertHas(
+ ByResource.text(
+ controller.getTargetResources(), R.string.dvr_schedules_empty_state),
false);
- assertHas(mDevice, By.textStartsWith(programName), true);
+ controller.assertHas(By.textStartsWith(programName), true);
// Moves to the series card, clicks it, the detail page should be shown with "View schedule"
// button.
- mDevice.pressBack();
- assertWaitForCondition(mDevice, Until.hasObject(Constants.DVR_LIBRARY));
- mDevice.pressDPadLeft();
- assertWaitUntilFocused(mDevice, newScheduleCard);
- mDevice.pressDPadDown();
- assertWaitUntilFocused(mDevice, seriesCardWithOneSchedule);
- mDevice.pressDPadCenter();
- assertWaitForCondition(mDevice, Until.gone(Constants.DVR_LIBRARY));
- assertHas(mDevice, By.text(mTargetResources
- .getString(R.string.dvr_detail_view_schedule).toUpperCase()), true);
- assertHas(mDevice, By.text(watchButton), false);
- assertHas(mDevice, By.text(mTargetResources
- .getString(R.string.dvr_detail_series_delete).toUpperCase()), false);
+ controller.pressBack();
+ controller.assertWaitForCondition(Until.hasObject(Constants.DVR_LIBRARY));
+ controller.pressDPadLeft();
+ controller.assertWaitUntilFocused(newScheduleCard);
+ controller.pressDPadDown();
+ controller.assertWaitUntilFocused(seriesCardWithOneSchedule);
+ controller.pressDPadCenter();
+ controller.assertWaitForCondition(Until.gone(Constants.DVR_LIBRARY));
+ controller.assertHas(
+ By.text(
+ controller
+ .getTargetResources()
+ .getString(R.string.dvr_detail_view_schedule)
+ .toUpperCase()),
+ true);
+ controller.assertHas(By.text(watchButton), false);
+ controller.assertHas(
+ By.text(
+ controller
+ .getTargetResources()
+ .getString(R.string.dvr_detail_series_delete)
+ .toUpperCase()),
+ false);
// Clicks the new schedule, the detail page should be shown with "Stop recording" button.
- mDevice.pressBack();
- assertWaitForCondition(mDevice, Until.hasObject(Constants.DVR_LIBRARY));
- assertWaitUntilFocused(mDevice, seriesCardWithOneSchedule);
- mDevice.pressDPadUp();
- assertWaitUntilFocused(mDevice, newScheduleCard);
- mDevice.pressDPadCenter();
- assertWaitForCondition(mDevice, Until.gone(Constants.DVR_LIBRARY));
- assertHas(mDevice, By.text(mTargetResources
- .getString(R.string.dvr_detail_stop_recording).toUpperCase()), true);
+ controller.pressBack();
+ controller.assertWaitForCondition(Until.hasObject(Constants.DVR_LIBRARY));
+ controller.assertWaitUntilFocused(seriesCardWithOneSchedule);
+ controller.pressDPadUp();
+ controller.assertWaitUntilFocused(newScheduleCard);
+ controller.pressDPadCenter();
+ controller.assertWaitForCondition(Until.gone(Constants.DVR_LIBRARY));
+ controller.assertHas(
+ By.text(
+ controller
+ .getTargetResources()
+ .getString(R.string.dvr_detail_stop_recording)
+ .toUpperCase()),
+ true);
// Stops the recording
- mDevice.pressDPadCenter();
- assertWaitForCondition(mDevice, Until.hasObject(
- ByResource.text(mTargetResources, R.string.dvr_action_stop)));
- mDevice.pressDPadCenter();
- assertWaitForCondition(mDevice, Until.gone(
- ByResource.text(mTargetResources, R.string.dvr_action_stop)));
- assertWaitForCondition(mDevice, Until.hasObject(Constants.DVR_LIBRARY));
- assertWaitUntilFocused(mDevice, mFullScheduleCard);
+ controller.pressDPadCenter();
+ controller.assertWaitForCondition(
+ Until.hasObject(
+ ByResource.text(
+ controller.getTargetResources(), R.string.dvr_action_stop)));
+ controller.pressDPadCenter();
+ controller.assertWaitForCondition(
+ Until.gone(
+ ByResource.text(
+ controller.getTargetResources(), R.string.dvr_action_stop)));
+ controller.assertWaitForCondition(Until.hasObject(Constants.DVR_LIBRARY));
+ controller.assertWaitUntilFocused(mFullScheduleCard);
// Moves to series' detail page again, now it should have two more buttons
- mDevice.pressDPadDown();
- assertWaitUntilFocused(mDevice, seriesCardWithOneRecordedProgram);
- mDevice.pressDPadCenter();
- assertWaitForCondition(mDevice, Until.gone(Constants.DVR_LIBRARY));
- assertHas(mDevice, By.text(watchButton), true);
- assertHas(mDevice, By.text(mTargetResources
- .getString(R.string.dvr_detail_view_schedule).toUpperCase()), true);
- assertHas(mDevice, By.text(mTargetResources
- .getString(R.string.dvr_detail_series_delete).toUpperCase()), true);
+ controller.pressDPadDown();
+ controller.assertWaitUntilFocused(seriesCardWithOneRecordedProgram);
+ controller.pressDPadCenter();
+ controller.assertWaitForCondition(Until.gone(Constants.DVR_LIBRARY));
+ controller.assertHas(By.text(watchButton), true);
+ controller.assertHas(
+ By.text(
+ controller
+ .getTargetResources()
+ .getString(R.string.dvr_detail_view_schedule)
+ .toUpperCase()),
+ true);
+ controller.assertHas(
+ By.text(
+ controller
+ .getTargetResources()
+ .getString(R.string.dvr_detail_series_delete)
+ .toUpperCase()),
+ true);
// Moves to the recent row and clicks the recent recorded program.
- mDevice.pressBack();
- assertWaitForCondition(mDevice, Until.hasObject(Constants.DVR_LIBRARY));
- assertWaitUntilFocused(mDevice, seriesCardWithOneRecordedProgram);
- mDevice.pressDPadUp();
- assertWaitUntilFocused(mDevice, mFullScheduleCard);
- mDevice.pressDPadUp();
- assertWaitUntilFocused(mDevice, By.focusable(true).hasDescendant(By.text(programName)));
- mDevice.pressDPadCenter();
- assertWaitForCondition(mDevice, Until.gone(Constants.DVR_LIBRARY));
- assertHas(mDevice, By.text(mTargetResources
- .getString(R.string.dvr_detail_watch).toUpperCase()), true);
- assertHas(mDevice, By.text(mTargetResources
- .getString(R.string.dvr_detail_delete).toUpperCase()), true);
+ controller.pressBack();
+ controller.assertWaitForCondition(Until.hasObject(Constants.DVR_LIBRARY));
+ controller.assertWaitUntilFocused(seriesCardWithOneRecordedProgram);
+ controller.pressDPadUp();
+ controller.assertWaitUntilFocused(mFullScheduleCard);
+ controller.pressDPadUp();
+ controller.assertWaitUntilFocused(By.focusable(true).hasDescendant(By.text(programName)));
+ controller.pressDPadCenter();
+ controller.assertWaitForCondition(Until.gone(Constants.DVR_LIBRARY));
+ controller.assertHas(
+ By.text(
+ controller
+ .getTargetResources()
+ .getString(R.string.dvr_detail_watch)
+ .toUpperCase()),
+ true);
+ controller.assertHas(
+ By.text(
+ controller
+ .getTargetResources()
+ .getString(R.string.dvr_detail_delete)
+ .toUpperCase()),
+ true);
// Moves to the delete button and clicks to remove the recorded program.
- mDevice.pressDPadRight();
- assertWaitUntilFocused(mDevice, By.text(mTargetResources
- .getString(R.string.dvr_detail_delete).toUpperCase()));
- mDevice.pressDPadCenter();
- assertWaitForCondition(mDevice, Until.hasObject(Constants.DVR_LIBRARY));
- assertWaitUntilFocused(mDevice, mFullScheduleCard);
+ controller.pressDPadRight();
+ controller.assertWaitUntilFocused(
+ By.text(
+ controller
+ .getTargetResources()
+ .getString(R.string.dvr_detail_delete)
+ .toUpperCase()));
+ controller.pressDPadCenter();
+ controller.assertWaitForCondition(Until.hasObject(Constants.DVR_LIBRARY));
+ controller.assertWaitUntilFocused(mFullScheduleCard);
// DVR Library should be empty now.
- assertHas(mDevice, mRecentRow, false);
- assertHas(mDevice, mScheduledRow, true);
- assertHas(mDevice, mSeriesRow, false);
+ controller.assertHas(mRecentRow, false);
+ controller.assertHas(mScheduledRow, true);
+ controller.assertHas(mSeriesRow, false);
// Close the DVR library.
- mDevice.pressBack();
- assertWaitForCondition(mDevice, Until.gone(Constants.DVR_LIBRARY));
+ controller.pressBack();
+ controller.assertWaitForCondition(Until.gone(Constants.DVR_LIBRARY));
}
}
diff --git a/tests/func/src/com/android/tv/tests/ui/sidepanel/CustomizeChannelListFragmentTest.java b/tests/func/src/com/android/tv/tests/ui/sidepanel/CustomizeChannelListFragmentTest.java
index deeb9bfd..09b855e2 100644
--- a/tests/func/src/com/android/tv/tests/ui/sidepanel/CustomizeChannelListFragmentTest.java
+++ b/tests/func/src/com/android/tv/tests/ui/sidepanel/CustomizeChannelListFragmentTest.java
@@ -16,37 +16,48 @@
package com.android.tv.tests.ui.sidepanel;
-import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertWaitForCondition;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
import android.graphics.Point;
-import android.support.test.filters.LargeTest;
+import android.support.test.filters.MediumTest;
import android.support.test.uiautomator.BySelector;
import android.support.test.uiautomator.Direction;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.Until;
-
import com.android.tv.R;
import com.android.tv.testing.uihelper.Constants;
-import com.android.tv.tests.ui.LiveChannelsTestCase;
+import com.android.tv.tests.ui.LiveChannelsTestController;
+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;
+
+/** Tests for @{link {@link com.android.tv.ui.sidepanel.CustomizeChannelListFragment} */
+@MediumTest
+@RunWith(JUnit4.class)
+public class CustomizeChannelListFragmentTest {
-@LargeTest
-public class CustomizeChannelListFragmentTest extends LiveChannelsTestCase {
+ @Rule public final LiveChannelsTestController controller = new LiveChannelsTestController();
private BySelector mBySettingsSidePanel;
private UiObject2 mTvView;
private Point mNormalTvViewCenter;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mLiveChannelsHelper.assertAppStarted();
- mTvView = mDevice.findObject(Constants.TV_VIEW);
+ @Before
+ public void setUp() throws Exception {
+
+ controller.liveChannelsHelper.assertAppStarted();
+ mTvView = controller.getUiDevice().findObject(Constants.TV_VIEW);
mNormalTvViewCenter = mTvView.getVisibleCenter();
assertNotNull(mNormalTvViewCenter);
- pressKeysForChannel(com.android.tv.testing.testinput.TvTestInputConstants.CH_2);
+ controller.pressKeysForChannel(com.android.tv.testing.testinput.TvTestInputConstants.CH_2);
// Wait until KeypadChannelSwitchView closes.
- assertWaitForCondition(mDevice, Until.hasObject(Constants.CHANNEL_BANNER));
- mBySettingsSidePanel = mSidePanelHelper.bySidePanelTitled(
- R.string.side_panel_title_settings);
+ controller.assertWaitForCondition(Until.hasObject(Constants.CHANNEL_BANNER));
+ mBySettingsSidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(R.string.side_panel_title_settings);
}
private void assertShrunkenTvView(boolean shrunkenExpected) {
@@ -58,60 +69,71 @@ public class CustomizeChannelListFragmentTest extends LiveChannelsTestCase {
}
}
+ @Test
public void testCustomizeChannelList_noraml() {
// Show customize channel list fragment
- mMenuHelper.assertPressOptionsSettings();
- assertWaitForCondition(mDevice, Until.hasObject(mBySettingsSidePanel));
- mSidePanelHelper.assertNavigateToItem(
+ controller.menuHelper.assertPressOptionsSettings();
+ controller.assertWaitForCondition(Until.hasObject(mBySettingsSidePanel));
+ controller.sidePanelHelper.assertNavigateToItem(
R.string.settings_channel_source_item_customize_channels);
- mDevice.pressDPadCenter();
- BySelector bySidePanel = mSidePanelHelper.bySidePanelTitled(
- R.string.side_panel_title_edit_channels_for_an_input);
- assertWaitForCondition(mDevice, Until.hasObject(bySidePanel));
+ controller.pressDPadCenter();
+ BySelector bySidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(
+ R.string.side_panel_title_edit_channels_for_an_input);
+ controller.assertWaitForCondition(Until.hasObject(bySidePanel));
assertShrunkenTvView(true);
// Show group by fragment
- mSidePanelHelper.assertNavigateToItem(R.string.edit_channels_item_group_by, Direction.UP);
- mDevice.pressDPadCenter();
- bySidePanel = mSidePanelHelper.bySidePanelTitled(R.string.side_panel_title_group_by);
- assertWaitForCondition(mDevice, Until.hasObject(bySidePanel));
+ controller.sidePanelHelper.assertNavigateToItem(
+ R.string.edit_channels_item_group_by, Direction.UP);
+ controller.pressDPadCenter();
+ bySidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(R.string.side_panel_title_group_by);
+ controller.assertWaitForCondition(Until.hasObject(bySidePanel));
assertShrunkenTvView(true);
// Back to customize channel list fragment
- mDevice.pressBack();
- bySidePanel = mSidePanelHelper.bySidePanelTitled(
- R.string.side_panel_title_edit_channels_for_an_input);
- assertWaitForCondition(mDevice, Until.hasObject(bySidePanel));
+ controller.pressBack();
+ bySidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(
+ R.string.side_panel_title_edit_channels_for_an_input);
+ controller.assertWaitForCondition(Until.hasObject(bySidePanel));
assertShrunkenTvView(true);
// Return to the main menu.
- mDevice.pressBack();
- assertWaitForCondition(mDevice, Until.hasObject(mBySettingsSidePanel));
+ controller.pressBack();
+ controller.assertWaitForCondition(Until.hasObject(mBySettingsSidePanel));
assertShrunkenTvView(false);
}
+ @Ignore("b/73727914")
+ @Test
public void testCustomizeChannelList_timeout() {
// Show customize channel list fragment
- mMenuHelper.assertPressOptionsSettings();
- assertWaitForCondition(mDevice, Until.hasObject(mBySettingsSidePanel));
- mSidePanelHelper.assertNavigateToItem(
+ controller.menuHelper.assertPressOptionsSettings();
+ controller.assertWaitForCondition(Until.hasObject(mBySettingsSidePanel));
+ controller.sidePanelHelper.assertNavigateToItem(
R.string.settings_channel_source_item_customize_channels);
- mDevice.pressDPadCenter();
- BySelector bySidePanel = mSidePanelHelper.bySidePanelTitled(
- R.string.side_panel_title_edit_channels_for_an_input);
- assertWaitForCondition(mDevice, Until.hasObject(bySidePanel));
+ controller.pressDPadCenter();
+ BySelector bySidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(
+ R.string.side_panel_title_edit_channels_for_an_input);
+ controller.assertWaitForCondition(Until.hasObject(bySidePanel));
assertShrunkenTvView(true);
// Show group by fragment
- mSidePanelHelper.assertNavigateToItem(R.string.edit_channels_item_group_by, Direction.UP);
- mDevice.pressDPadCenter();
- bySidePanel = mSidePanelHelper.bySidePanelTitled(R.string.side_panel_title_group_by);
- assertWaitForCondition(mDevice, Until.hasObject(bySidePanel));
+ controller.sidePanelHelper.assertNavigateToItem(
+ R.string.edit_channels_item_group_by, Direction.UP);
+ controller.pressDPadCenter();
+ bySidePanel =
+ controller.sidePanelHelper.bySidePanelTitled(R.string.side_panel_title_group_by);
+ controller.assertWaitForCondition(Until.hasObject(bySidePanel));
assertShrunkenTvView(true);
// Wait for time-out to return to the main menu.
- assertWaitForCondition(mDevice, Until.gone(bySidePanel),
- mTargetResources.getInteger(R.integer.side_panel_show_duration));
+ controller.assertWaitForCondition(
+ Until.gone(bySidePanel),
+ controller.getTargetResources().getInteger(R.integer.side_panel_show_duration));
assertShrunkenTvView(false);
}
}