diff options
Diffstat (limited to 'tests/func/src/com/android/tv/tests/ui/sidepanel/CustomizeChannelListFragmentTest.java')
-rw-r--r-- | tests/func/src/com/android/tv/tests/ui/sidepanel/CustomizeChannelListFragmentTest.java | 112 |
1 files changed, 67 insertions, 45 deletions
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); } } |