aboutsummaryrefslogtreecommitdiff
path: root/tests/jank/src/com/android/tv/tests/jank/MenuJankTest.java
blob: 411a0bb9c855cdf73b03ca0ae060899d693043af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * 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.support.test.filters.MediumTest;
import android.support.test.jank.GfxMonitor;
import android.support.test.jank.JankTest;

import com.android.tv.testing.uihelper.MenuHelper;

/**
 * Jank tests for the program guide.
 */
@MediumTest
public class MenuJankTest extends LiveChannelsTestCase {
    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 MenuHelper mMenuHelper;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        mMenuHelper = new MenuHelper(mDevice, mTargetResources);
        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();
        }
    }
}