165fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko/* 265fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * Copyright (C) 2016 The Android Open Source Project 365fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * 465fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * Licensed under the Apache License, Version 2.0 (the "License"); 565fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * you may not use this file except in compliance with the License. 665fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * You may obtain a copy of the License at 765fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * 865fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * http://www.apache.org/licenses/LICENSE-2.0 965fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * 1065fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * Unless required by applicable law or agreed to in writing, software 1165fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * distributed under the License is distributed on an "AS IS" BASIS, 1265fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1365fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * See the License for the specific language governing permissions and 1465fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * limitations under the License. 1565fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko */ 1665fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalkopackage com.android.tv.tests.jank; 1765fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko 1865fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalkoimport android.support.test.filters.MediumTest; 1965fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalkoimport android.support.test.jank.GfxMonitor; 2065fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalkoimport android.support.test.jank.JankTest; 2165fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko 2265fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko/** 2365fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * Jank tests for channel zapping. 2465fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko */ 2565fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko@MediumTest 266ebde20b03db4c0d57f67acaac11832b610b966bNick Chalkopublic class ChannelZappingJankTest extends LiveChannelsTestCase { 2765fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko private static final String TAG = "ChannelZappingJankTest"; 2865fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko 2965fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko private static final String STARTING_CHANNEL = "13"; 3065fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko 3165fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko /** 3265fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * The minimum number of frames expected during each jank test. 3365fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * If there is less the test will fail. To be safe we loop the action in each test to create 3465fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * twice this many frames under normal conditions. 3565fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * <p>At least 100 frams should be chosen so there will be enough frame 3665fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * for the 90th, 95th, and 98th percentile measurements are significant. 3765fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * 3865fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko * @see <a href="http://go/janktesthelper-best-practices">Jank Test Helper Best Practices</a> 3965fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko */ 4065fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko private static final int EXPECTED_FRAMES = 100; 4165fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko private static final int WARM_UP_CHANNEL_ZAPPING_COUNT = 2; 4265fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko 4365fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko @Override 4465fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko protected void setUp() throws Exception { 4565fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko super.setUp(); 4665fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko Utils.pressKeysForChannelNumber(STARTING_CHANNEL, mDevice); 4765fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko } 4865fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko 4965fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko @JankTest(expectedFrames = EXPECTED_FRAMES, 5065fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko beforeTest = "warmChannelZapping") 5165fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko @GfxMonitor(processName = Utils.LIVE_CHANNELS_PROCESS_NAME) 5265fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko public void testChannelZapping() { 5365fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko int frameCountForOneChannelZapping = 40; // measured by hand 5465fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko int repeat = EXPECTED_FRAMES * 2 / frameCountForOneChannelZapping; 5565fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko for (int i = 0; i < repeat; i++) { 5665fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko mDevice.pressDPadUp(); 5765fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko mDevice.waitForIdle(); 5865fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko // Press BACK to close banner. 5965fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko mDevice.pressBack(); 6065fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko mDevice.waitForIdle(); 6165fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko } 6265fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko } 6365fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko 6465fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko // It's public to be used with @JankTest annotation. 6565fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko public void warmChannelZapping() { 6665fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko for (int i = 0; i < WARM_UP_CHANNEL_ZAPPING_COUNT; ++i) { 6765fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko mDevice.pressDPadUp(); 6865fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko mDevice.waitForIdle(); 6965fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko } 7065fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko // Press BACK to close banner. 7165fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko mDevice.pressBack(); 7265fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko mDevice.waitForIdle(); 7365fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko } 7465fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko} 75