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.java86
-rw-r--r--tests/jank/src/com/android/tv/tests/jank/MenuJankTest.java84
-rw-r--r--tests/jank/src/com/android/tv/tests/jank/ProgramGuideJankTest.java41
-rw-r--r--tests/jank/src/com/android/tv/tests/jank/Utils.java35
4 files changed, 220 insertions, 26 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
new file mode 100644
index 00000000..b0463e71
--- /dev/null
+++ b/tests/jank/src/com/android/tv/tests/jank/ChannelZappingJankTest.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2016 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.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 {
+ private static final String TAG = "ChannelZappingJankTest";
+
+ private static final String STARTING_CHANNEL = "13";
+
+ /**
+ * The minimum number of frames expected during each jank test.
+ * If there is less the test will fail. To be safe we loop the action in each test to create
+ * twice this many frames under normal conditions.
+ * <p>At least 100 frams should be chosen so there will be enough frame
+ * for the 90th, 95th, and 98th percentile measurements are significant.
+ *
+ * @see <a href="http://go/janktesthelper-best-practices">Jank Test Helper Best Practices</a>
+ */
+ 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);
+ }
+
+ @JankTest(expectedFrames = EXPECTED_FRAMES,
+ beforeTest = "warmChannelZapping")
+ @GfxMonitor(processName = Utils.LIVE_CHANNELS_PROCESS_NAME)
+ public void testChannelZapping() {
+ int frameCountForOneChannelZapping = 40; // measured by hand
+ int repeat = EXPECTED_FRAMES * 2 / frameCountForOneChannelZapping;
+ for (int i = 0; i < repeat; i++) {
+ mDevice.pressDPadUp();
+ mDevice.waitForIdle();
+ // Press BACK to close banner.
+ mDevice.pressBack();
+ mDevice.waitForIdle();
+ }
+ }
+
+ // It's public to be used with @JankTest annotation.
+ public void warmChannelZapping() {
+ for (int i = 0; i < WARM_UP_CHANNEL_ZAPPING_COUNT; ++i) {
+ mDevice.pressDPadUp();
+ mDevice.waitForIdle();
+ }
+ // Press BACK to close banner.
+ mDevice.pressBack();
+ mDevice.waitForIdle();
+ }
+}
diff --git a/tests/jank/src/com/android/tv/tests/jank/MenuJankTest.java b/tests/jank/src/com/android/tv/tests/jank/MenuJankTest.java
new file mode 100644
index 00000000..47ebea3b
--- /dev/null
+++ b/tests/jank/src/com/android/tv/tests/jank/MenuJankTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2016 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.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 {
+ private static final String STARTING_CHANNEL = "1";
+
+ /**
+ * The minimum number of frames expected during each jank test.
+ * If there is less the test will fail. To be safe we loop the action in each test to create
+ * twice this many frames under normal conditions.
+ * <p>200 is chosen so there will be enough frame for the 90th, 95th, and 98th percentile
+ * measurements are significant.
+ *
+ * @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);
+ }
+
+ @JankTest(expectedFrames = EXPECTED_FRAMES,
+ beforeTest = "fillTheMenuRowWithPreviousChannels")
+ @GfxMonitor(processName = Utils.LIVE_CHANNELS_PROCESS_NAME)
+ public void testShowMenu() {
+ int frames = 40; // measured by hand.
+ int repeat = EXPECTED_FRAMES * 2 / frames;
+ for (int i = 0; i < repeat; i++) {
+ mMenuHelper.showMenu();
+ mDevice.pressBack();
+ mDevice.waitForIdle();
+ }
+ }
+
+ public void fillTheMenuRowWithPreviousChannels() {
+ int cardViewCount = 6;
+ for (int i = 0; i < cardViewCount; i++) {
+ mDevice.pressDPadUp();
+ mDevice.waitForIdle();
+ }
+ }
+}
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 bec933ca..7d751c4c 100644
--- a/tests/jank/src/com/android/tv/tests/jank/ProgramGuideJankTest.java
+++ b/tests/jank/src/com/android/tv/tests/jank/ProgramGuideJankTest.java
@@ -18,14 +18,12 @@ package com.android.tv.tests.jank;
import static com.android.tv.testing.uihelper.UiDeviceAsserts.assertWaitForCondition;
import android.content.res.Resources;
-import android.os.Build;
-import android.support.test.filters.SdkSuppress;
+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 android.test.suitebuilder.annotation.MediumTest;
import com.android.tv.R;
import com.android.tv.testing.uihelper.ByResource;
@@ -38,13 +36,11 @@ import com.android.tv.testing.uihelper.UiDeviceUtils;
* Jank tests for the program guide.
*/
@MediumTest
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.M)
public class ProgramGuideJankTest extends JankTestBase {
private static final boolean DEBUG = false;
private static final String TAG = "ProgramGuideJank";
private static final String STARTING_CHANNEL = "13";
- public static final String LIVE_CHANNELS_PROCESS_NAME = "com.android.tv";
/**
* The minimum number of frames expected during each jank test.
@@ -56,13 +52,11 @@ public class ProgramGuideJankTest extends JankTestBase {
* @see <a href="http://go/janktesthelper-best-practices">Jank Test Helper Best Practices</a>
*/
private static final int EXPECTED_FRAMES = 200;
- public static final String LIVE_CHANNELS_PACKAGE = "com.android.tv";
- protected UiDevice mDevice;
+ private UiDevice mDevice;
- protected Resources mTargetResources;
- protected MenuHelper mMenuHelper;
- protected LiveChannelsUiDeviceHelper mLiveChannelsHelper;
+ private Resources mTargetResources;
+ private MenuHelper mMenuHelper;
@Override
protected void setUp() throws Exception {
@@ -70,16 +64,15 @@ public class ProgramGuideJankTest extends JankTestBase {
mDevice = UiDevice.getInstance(getInstrumentation());
mTargetResources = getInstrumentation().getTargetContext().getResources();
mMenuHelper = new MenuHelper(mDevice, mTargetResources);
- mLiveChannelsHelper = new LiveChannelsUiDeviceHelper(mDevice, mTargetResources,
- getInstrumentation().getContext());
- mLiveChannelsHelper.assertAppStarted();
- pressKeysForChannelNumber(STARTING_CHANNEL);
+ LiveChannelsUiDeviceHelper liveChannelsHelper = new LiveChannelsUiDeviceHelper(mDevice,
+ mTargetResources, getInstrumentation().getContext());
+ liveChannelsHelper.assertAppStarted();
+ Utils.pressKeysForChannelNumber(STARTING_CHANNEL, mDevice);
}
-
@JankTest(expectedFrames = EXPECTED_FRAMES,
beforeTest = "warmProgramGuide")
- @GfxMonitor(processName = LIVE_CHANNELS_PACKAGE)
+ @GfxMonitor(processName = Utils.LIVE_CHANNELS_PROCESS_NAME)
public void testShowClearProgramGuide() {
int frames = 53; // measured by hand
int repeat = EXPECTED_FRAMES * 2 / frames;
@@ -92,7 +85,7 @@ public class ProgramGuideJankTest extends JankTestBase {
@JankTest(expectedFrames = EXPECTED_FRAMES,
beforeLoop = "showProgramGuide",
afterLoop = "clearProgramGuide")
- @GfxMonitor(processName = LIVE_CHANNELS_PROCESS_NAME)
+ @GfxMonitor(processName = Utils.LIVE_CHANNELS_PROCESS_NAME)
public void testScrollDown() {
int frames = 20; // measured by hand
int repeat = EXPECTED_FRAMES * 2 / frames;
@@ -104,7 +97,7 @@ public class ProgramGuideJankTest extends JankTestBase {
@JankTest(expectedFrames = EXPECTED_FRAMES,
beforeLoop = "showProgramGuide",
afterLoop = "clearProgramGuide")
- @GfxMonitor(processName = LIVE_CHANNELS_PROCESS_NAME)
+ @GfxMonitor(processName = Utils.LIVE_CHANNELS_PROCESS_NAME)
public void testScrollRight() {
int frames = 30; // measured by hand
int repeat = EXPECTED_FRAMES * 2 / frames;
@@ -113,33 +106,29 @@ public class ProgramGuideJankTest extends JankTestBase {
}
}
- //TODO: move to a mixin/helper
- protected void pressKeysForChannelNumber(String channel) {
- UiDeviceUtils.pressKeys(mDevice, channel);
- mDevice.pressDPadCenter();
- }
-
- public void selectProgramGuideMenuItem() {
+ private void selectProgramGuideMenuItem() {
mMenuHelper.showMenu();
mMenuHelper.assertNavigateToMenuItem(R.string.menu_title_channels,
R.string.channels_item_program_guide);
mDevice.waitForIdle();
}
+ // It's public to be used with @JankTest annotation.
public void warmProgramGuide() {
// TODO: b/21078199 First time Program Guide is opened there is a noticeable delay
selectProgramGuideMenuItem();
mDevice.pressDPadCenter();
assertWaitForCondition(mDevice, Until.hasObject(Constants.PROGRAM_GUIDE));
mDevice.pressBack();
-
}
+ // It's public to be used with @JankTest annotation.
public void clearProgramGuide() {
mDevice.pressBack();
assertWaitForCondition(mDevice, Until.gone(Constants.PROGRAM_GUIDE));
}
+ // It's public to be used with @JankTest annotation.
public void showProgramGuide() {
selectProgramGuideMenuItem();
mDevice.pressDPadCenter();
diff --git a/tests/jank/src/com/android/tv/tests/jank/Utils.java b/tests/jank/src/com/android/tv/tests/jank/Utils.java
new file mode 100644
index 00000000..cd1f7eff
--- /dev/null
+++ b/tests/jank/src/com/android/tv/tests/jank/Utils.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2016 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 com.android.tv.testing.uihelper.UiDeviceUtils;
+
+import android.support.test.uiautomator.UiDevice;
+
+public final class Utils {
+ /** Live TV process name */
+ public static final String LIVE_CHANNELS_PROCESS_NAME = "com.android.tv";
+
+ private Utils() { }
+
+ /**
+ * Presses channel number to tune to {@code channel}.
+ */
+ public static void pressKeysForChannelNumber(String channel, UiDevice uiDevice) {
+ UiDeviceUtils.pressKeys(uiDevice, channel);
+ uiDevice.pressDPadCenter();
+ }
+}