Home | History | Annotate | Download | only in ui
      1 /*
      2  * Copyright (C) 2015 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package com.android.tv.tests.ui;
     17 
     18 import android.support.test.filters.MediumTest;
     19 import android.support.test.uiautomator.BySelector;
     20 import android.support.test.uiautomator.Until;
     21 import com.android.tv.R;
     22 import com.android.tv.testing.uihelper.ByResource;
     23 import org.junit.Before;
     24 import org.junit.Rule;
     25 import org.junit.Test;
     26 import org.junit.runner.RunWith;
     27 import org.junit.runners.JUnit4;
     28 
     29 /** Tests for channel sources. */
     30 @MediumTest
     31 @RunWith(JUnit4.class)
     32 public class ChannelSourcesTest {
     33     @Rule public final LiveChannelsTestController controller = new LiveChannelsTestController();
     34     private BySelector mBySettingsSidePanel;
     35 
     36     @Before
     37     public void before() throws Exception {
     38         mBySettingsSidePanel =
     39                 controller.sidePanelHelper.bySidePanelTitled(R.string.side_panel_title_settings);
     40     }
     41 
     42     // TODO: create a cancelable test channel setup.
     43 
     44     @Test
     45     public void testSetup_cancel() {
     46         controller.liveChannelsHelper.assertAppStarted();
     47         controller.menuHelper.assertPressOptionsSettings();
     48         controller.assertWaitForCondition(Until.hasObject(mBySettingsSidePanel));
     49 
     50         controller.sidePanelHelper.assertNavigateToItem(
     51                 R.string.settings_channel_source_item_setup);
     52         controller.pressDPadCenter();
     53 
     54         controller.assertWaitForCondition(
     55                 Until.hasObject(
     56                         ByResource.text(
     57                                 controller.getTargetResources(), R.string.setup_sources_text)));
     58         controller.pressBack();
     59     }
     60 
     61     // SetupSourcesFragment should have no errors if side fragment item is clicked multiple times.
     62     @Test
     63     public void testSetupTwice_cancel() {
     64         controller.liveChannelsHelper.assertAppStarted();
     65         controller.menuHelper.assertPressOptionsSettings();
     66         controller.assertWaitForCondition(Until.hasObject(mBySettingsSidePanel));
     67 
     68         controller.sidePanelHelper.assertNavigateToItem(
     69                 R.string.settings_channel_source_item_setup);
     70         controller.pressDPadCenter(2);
     71 
     72         controller.assertWaitForCondition(
     73                 Until.hasObject(
     74                         ByResource.text(
     75                                 controller.getTargetResources(), R.string.setup_sources_text)));
     76         controller.pressBack();
     77     }
     78 }
     79