aboutsummaryrefslogtreecommitdiff
path: root/tests/jank/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'tests/jank/src/com')
-rw-r--r--tests/jank/src/com/android/tv/tests/jank/ChannelZappingJankTest.java14
-rw-r--r--tests/jank/src/com/android/tv/tests/jank/LiveChannelsTestCase.java48
-rw-r--r--tests/jank/src/com/android/tv/tests/jank/MenuJankTest.java16
-rw-r--r--tests/jank/src/com/android/tv/tests/jank/ProgramGuideJankTest.java30
4 files changed, 60 insertions, 48 deletions
diff --git a/tests/jank/src/com/android/tv/tests/jank/ChannelZappingJankTest.java b/tests/jank/src/com/android/tv/tests/jank/ChannelZappingJankTest.java
index b0463e71..ef936e32 100644
--- a/tests/jank/src/com/android/tv/tests/jank/ChannelZappingJankTest.java
+++ b/tests/jank/src/com/android/tv/tests/jank/ChannelZappingJankTest.java
@@ -15,20 +15,15 @@
*/
package com.android.tv.tests.jank;
-import android.content.res.Resources;
import android.support.test.filters.MediumTest;
import android.support.test.jank.GfxMonitor;
import android.support.test.jank.JankTest;
-import android.support.test.jank.JankTestBase;
-import android.support.test.uiautomator.UiDevice;
-
-import com.android.tv.testing.uihelper.LiveChannelsUiDeviceHelper;
/**
* Jank tests for channel zapping.
*/
@MediumTest
-public class ChannelZappingJankTest extends JankTestBase {
+public class ChannelZappingJankTest extends LiveChannelsTestCase {
private static final String TAG = "ChannelZappingJankTest";
private static final String STARTING_CHANNEL = "13";
@@ -45,16 +40,9 @@ public class ChannelZappingJankTest extends JankTestBase {
private static final int EXPECTED_FRAMES = 100;
private static final int WARM_UP_CHANNEL_ZAPPING_COUNT = 2;
- private UiDevice mDevice;
-
@Override
protected void setUp() throws Exception {
super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- Resources targetResources = getInstrumentation().getTargetContext().getResources();
- LiveChannelsUiDeviceHelper liveChannelsHelper = new LiveChannelsUiDeviceHelper(mDevice,
- targetResources, getInstrumentation().getContext());
- liveChannelsHelper.assertAppStarted();
Utils.pressKeysForChannelNumber(STARTING_CHANNEL, mDevice);
}
diff --git a/tests/jank/src/com/android/tv/tests/jank/LiveChannelsTestCase.java b/tests/jank/src/com/android/tv/tests/jank/LiveChannelsTestCase.java
new file mode 100644
index 00000000..6de01036
--- /dev/null
+++ b/tests/jank/src/com/android/tv/tests/jank/LiveChannelsTestCase.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2017 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.jank;
+
+import android.content.res.Resources;
+import android.support.test.jank.JankTestBase;
+import android.support.test.uiautomator.UiDevice;
+
+import com.android.tv.testing.uihelper.LiveChannelsUiDeviceHelper;
+
+/**
+ * Base test case for LiveChannel jank tests.
+ */
+abstract class LiveChannelsTestCase extends JankTestBase {
+ protected UiDevice mDevice;
+ protected Resources mTargetResources;
+ protected LiveChannelsUiDeviceHelper mLiveChannelsHelper;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mDevice = UiDevice.getInstance(getInstrumentation());
+ mTargetResources = getInstrumentation().getTargetContext().getResources();
+ mLiveChannelsHelper = new LiveChannelsUiDeviceHelper(mDevice, mTargetResources,
+ getInstrumentation().getContext());
+ mLiveChannelsHelper.assertAppStarted();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ // Destroys the activity to make sure next test case's activity launch check works well.
+ mLiveChannelsHelper.assertAppStopped();
+ super.tearDown();
+ }
+}
diff --git a/tests/jank/src/com/android/tv/tests/jank/MenuJankTest.java b/tests/jank/src/com/android/tv/tests/jank/MenuJankTest.java
index 47ebea3b..411a0bb9 100644
--- a/tests/jank/src/com/android/tv/tests/jank/MenuJankTest.java
+++ b/tests/jank/src/com/android/tv/tests/jank/MenuJankTest.java
@@ -15,21 +15,17 @@
*/
package com.android.tv.tests.jank;
-import android.content.res.Resources;
import android.support.test.filters.MediumTest;
import android.support.test.jank.GfxMonitor;
import android.support.test.jank.JankTest;
-import android.support.test.jank.JankTestBase;
-import android.support.test.uiautomator.UiDevice;
-import com.android.tv.testing.uihelper.LiveChannelsUiDeviceHelper;
import com.android.tv.testing.uihelper.MenuHelper;
/**
* Jank tests for the program guide.
*/
@MediumTest
-public class MenuJankTest extends JankTestBase {
+public class MenuJankTest extends LiveChannelsTestCase {
private static final String STARTING_CHANNEL = "1";
/**
@@ -42,22 +38,12 @@ public class MenuJankTest extends JankTestBase {
* @see <a href="http://go/janktesthelper-best-practices">Jank Test Helper Best Practices</a>
*/
private static final int EXPECTED_FRAMES = 200;
-
- protected UiDevice mDevice;
-
- protected Resources mTargetResources;
protected MenuHelper mMenuHelper;
- protected LiveChannelsUiDeviceHelper mLiveChannelsHelper;
@Override
protected void setUp() throws Exception {
super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- mTargetResources = getInstrumentation().getTargetContext().getResources();
mMenuHelper = new MenuHelper(mDevice, mTargetResources);
- mLiveChannelsHelper = new LiveChannelsUiDeviceHelper(mDevice, mTargetResources,
- getInstrumentation().getContext());
- mLiveChannelsHelper.assertAppStarted();
Utils.pressKeysForChannelNumber(STARTING_CHANNEL, mDevice);
}
diff --git a/tests/jank/src/com/android/tv/tests/jank/ProgramGuideJankTest.java b/tests/jank/src/com/android/tv/tests/jank/ProgramGuideJankTest.java
index 7d751c4c..d8860dd7 100644
--- a/tests/jank/src/com/android/tv/tests/jank/ProgramGuideJankTest.java
+++ b/tests/jank/src/com/android/tv/tests/jank/ProgramGuideJankTest.java
@@ -17,29 +17,21 @@ package com.android.tv.tests.jank;
import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertWaitForCondition;
-import android.content.res.Resources;
import android.support.test.filters.MediumTest;
import android.support.test.jank.GfxMonitor;
import android.support.test.jank.JankTest;
-import android.support.test.jank.JankTestBase;
-import android.support.test.uiautomator.UiDevice;
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.testing.uihelper.LiveChannelsUiDeviceHelper;
import com.android.tv.testing.uihelper.MenuHelper;
-import com.android.tv.testing.uihelper.UiDeviceUtils;
/**
* Jank tests for the program guide.
*/
@MediumTest
-public class ProgramGuideJankTest extends JankTestBase {
- private static final boolean DEBUG = false;
- private static final String TAG = "ProgramGuideJank";
-
+public class ProgramGuideJankTest extends LiveChannelsTestCase {
private static final String STARTING_CHANNEL = "13";
/**
@@ -53,20 +45,12 @@ public class ProgramGuideJankTest extends JankTestBase {
*/
private static final int EXPECTED_FRAMES = 200;
- private UiDevice mDevice;
-
- private Resources mTargetResources;
private MenuHelper mMenuHelper;
@Override
protected void setUp() throws Exception {
super.setUp();
- mDevice = UiDevice.getInstance(getInstrumentation());
- mTargetResources = getInstrumentation().getTargetContext().getResources();
mMenuHelper = new MenuHelper(mDevice, mTargetResources);
- LiveChannelsUiDeviceHelper liveChannelsHelper = new LiveChannelsUiDeviceHelper(mDevice,
- mTargetResources, getInstrumentation().getContext());
- liveChannelsHelper.assertAppStarted();
Utils.pressKeysForChannelNumber(STARTING_CHANNEL, mDevice);
}
@@ -83,7 +67,7 @@ public class ProgramGuideJankTest extends JankTestBase {
}
@JankTest(expectedFrames = EXPECTED_FRAMES,
- beforeLoop = "showProgramGuide",
+ beforeLoop = "showAndFocusProgramGuide",
afterLoop = "clearProgramGuide")
@GfxMonitor(processName = Utils.LIVE_CHANNELS_PROCESS_NAME)
public void testScrollDown() {
@@ -95,7 +79,7 @@ public class ProgramGuideJankTest extends JankTestBase {
}
@JankTest(expectedFrames = EXPECTED_FRAMES,
- beforeLoop = "showProgramGuide",
+ beforeLoop = "showAndFocusProgramGuide",
afterLoop = "clearProgramGuide")
@GfxMonitor(processName = Utils.LIVE_CHANNELS_PROCESS_NAME)
public void testScrollRight() {
@@ -128,11 +112,17 @@ public class ProgramGuideJankTest extends JankTestBase {
assertWaitForCondition(mDevice, Until.gone(Constants.PROGRAM_GUIDE));
}
- // It's public to be used with @JankTest annotation.
public void showProgramGuide() {
selectProgramGuideMenuItem();
mDevice.pressDPadCenter();
assertWaitForCondition(mDevice, Until.hasObject(Constants.PROGRAM_GUIDE));
+ }
+
+ // It's public to be used with @JankTest annotation.
+ public void showAndFocusProgramGuide() {
+ selectProgramGuideMenuItem();
+ mDevice.pressDPadCenter();
+ assertWaitForCondition(mDevice, Until.hasObject(Constants.PROGRAM_GUIDE));
// If the side panel grid is visible (and thus has focus), move right to clear it.
if (mDevice.hasObject(
ByResource.id(mTargetResources, R.id.program_guide_side_panel_grid_view))) {