FileDocCategorySizeDatePackage
WebViewFlingTest.javaAPI DocAndroid 5.1 API4794Thu Mar 12 22:22:56 GMT 2015com.android.uiautomator.platform

WebViewFlingTest

public class WebViewFlingTest extends com.android.uiautomator.janktesthelper.JankTestBase
Jank test for Android Webview. To run 1) Install the test application (com.android.webview.chromium.shell) 2) Place a directories containing the test pages on the test device in $EXTERNAL_STORAGE/AwJankPages. Each directory should contain an index.html file as the main file of the test page. 3) Build this test and push the resulting Jar file to /data/local/tmp/WebViewJankTests.jar 4) Run the test using the command: adb shell uiautomator runtest WebViewJankTests.jar The test will run for each of the test pages. The results will be saved on the device in /data/local/tmp/jankoutput.txt.

Fields Summary
private static final long
TEST_DELAY_TIME_MS
private static final long
PAGE_LOAD_DELAY_TIMEOUT_MS
private static final long
PAGE_LOAD_DELAY_TIME_MS
private static final int
MIN_DATA_SIZE
private static final String
AW_WINDOW_NAME
private static final String
AW_CONTAINER
private static final String
START_CMD
private com.android.uiautomator.core.UiScrollable
mWebPageDisplay
Constructors Summary
Methods Summary
private voidflingForward()

        getContainer().flingForward();
    
private com.android.uiautomator.core.UiScrollablegetContainer()

        if (mWebPageDisplay == null) {
            mWebPageDisplay =
                    new UiScrollable(new UiSelector().resourceId(AW_CONTAINER).instance(0));
            assertTrue("Failed to get web container",
                mWebPageDisplay.waitForExists(PAGE_LOAD_DELAY_TIMEOUT_MS));
        }
        return mWebPageDisplay;
    
private voidloadUrl(java.lang.String url)

        Runtime.getRuntime().exec(START_CMD + url);
        // Need to find a good way of detecting when the page is loaded
        sleep(PAGE_LOAD_DELAY_TIME_MS);
    
private voidresetFlingTest()

        getContainer().flingToBeginning(20);
    
private voidrunBrowserPageFling(java.io.File testFile)

        loadUrl("file://" + testFile.getAbsolutePath());
        for (int i = 0; i < getIteration(); i++) {
            resetFlingTest();
            sleep(TEST_DELAY_TIME_MS);
            startTrace(mTestCaseName, i);
            getSurfaceFlingerHelper().clearBuffer(AW_WINDOW_NAME);
            flingForward();
            sleep(DEFAULT_ANIMATION_TIME);
            boolean result =
                    getSurfaceFlingerHelper().dumpFrameLatency(AW_WINDOW_NAME, true);
            assertTrue("dump frame latency failed", result);

            waitForTrace();
            assertTrue(String.format("Sample size is less than expected: %d", MIN_DATA_SIZE),
                    validateResults(MIN_DATA_SIZE));
            // record the result in an array
            recordResults(mTestCaseName, i);
        }
        // calculate average and save the results
        saveResults(mTestCaseName);
    
protected voidsetUp()
{@inheritDoc}

        super.setUp();
        getUiDevice().setOrientationNatural();
    
protected voidtearDown()
{@inheritDoc}

        getUiDevice().unfreezeRotation();
        super.tearDown();
    
public voidtestBrowserPageFling()


          
        String url = mParams.getString("Url");
        File webpage = new File(url);
        assertNotNull("No test pages", webpage);
        runBrowserPageFling(webpage);