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 17 package com.android.uibench.janktests; 18 19 import static com.android.uibench.janktests.UiBenchJankTestsHelper.EXPECTED_FRAMES; 20 import static com.android.uibench.janktests.UiBenchJankTestsHelper.PACKAGE_NAME; 21 22 import android.support.test.jank.GfxMonitor; 23 import android.support.test.jank.JankTest; 24 import android.support.test.jank.JankTestBase; 25 import android.support.test.uiautomator.By; 26 import android.support.test.uiautomator.UiDevice; 27 import android.support.test.uiautomator.Until; 28 29 /** 30 * Jank benchmark WebView tests from UiBench app 31 */ 32 33 public class UiBenchWebView extends JankTestBase { 34 35 private UiDevice mDevice; 36 private UiBenchJankTestsHelper mHelper; 37 38 @Override 39 public void setUp() throws Exception { 40 super.setUp(); 41 mDevice = UiDevice.getInstance(getInstrumentation()); 42 mDevice.setOrientationNatural(); 43 mHelper = UiBenchJankTestsHelper.getInstance(this.getInstrumentation().getContext(), 44 mDevice); 45 } 46 47 @Override 48 protected void tearDown() throws Exception { 49 mDevice.unfreezeRotation(); 50 super.tearDown(); 51 } 52 53 // Open Scrollable WebView from WebView test 54 public void openScrollableWebView() { 55 mHelper.launchActivity("ScrollableWebViewActivity", 56 "WebView/Scrollable WebView"); 57 mHelper.mContents = mDevice.wait(Until.findObject( 58 By.res("android", "content")), mHelper.TIMEOUT); 59 } 60 61 // Test Scrollable WebView fling 62 @JankTest(beforeTest = "openScrollableWebView", expectedFrames = EXPECTED_FRAMES) 63 @GfxMonitor(processName = PACKAGE_NAME) 64 public void testWebViewFling() { 65 mHelper.flingUpDown(mHelper.mContents, 1); 66 } 67 68 } 69