1 /* 2 * Copyright (C) 2016 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.jank; 17 18 import android.support.test.filters.MediumTest; 19 import android.support.test.jank.GfxMonitor; 20 import android.support.test.jank.JankTest; 21 22 /** Jank tests for channel zapping. */ 23 @MediumTest 24 public class ChannelZappingJankTest extends LiveChannelsTestCase { 25 private static final String TAG = "ChannelZappingJankTest"; 26 27 private static final String STARTING_CHANNEL = "13"; 28 29 /** 30 * The minimum number of frames expected during each jank test. If there is less the test will 31 * fail. To be safe we loop the action in each test to create twice this many frames under 32 * normal conditions. 33 * 34 * <p>At least 100 frams should be chosen so there will be enough frame for the 90th, 95th, and 35 * 98th percentile measurements are significant. 36 * 37 * @see <a href="http://go/janktesthelper-best-practices">Jank Test Helper Best Practices</a> 38 */ 39 private static final int EXPECTED_FRAMES = 100; 40 41 private static final int WARM_UP_CHANNEL_ZAPPING_COUNT = 2; 42 43 @Override 44 protected void setUp() throws Exception { 45 super.setUp(); 46 Utils.pressKeysForChannelNumber(STARTING_CHANNEL, mDevice); 47 } 48 49 @JankTest(expectedFrames = EXPECTED_FRAMES, beforeTest = "warmChannelZapping") 50 @GfxMonitor(processName = Utils.LIVE_CHANNELS_PROCESS_NAME) 51 public void testChannelZapping() { 52 int frameCountForOneChannelZapping = 40; // measured by hand 53 int repeat = EXPECTED_FRAMES * 2 / frameCountForOneChannelZapping; 54 for (int i = 0; i < repeat; i++) { 55 mDevice.pressDPadUp(); 56 mDevice.waitForIdle(); 57 // Press BACK to close banner. 58 mDevice.pressBack(); 59 mDevice.waitForIdle(); 60 } 61 } 62 63 // It's public to be used with @JankTest annotation. 64 public void warmChannelZapping() { 65 for (int i = 0; i < WARM_UP_CHANNEL_ZAPPING_COUNT; ++i) { 66 mDevice.pressDPadUp(); 67 mDevice.waitForIdle(); 68 } 69 // Press BACK to close banner. 70 mDevice.pressBack(); 71 mDevice.waitForIdle(); 72 } 73 } 74