1 /* 2 * Copyright (C) 2015 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 android.windowanimationjank; 18 19 import android.os.Bundle; 20 import android.support.test.jank.JankTest; 21 import android.support.test.jank.GfxMonitor; 22 23 /** 24 * Detect janks during screen rotation for full-screen activity. Periodically change 25 * orientation from left to right and track ElementLayoutActivity rendering performance 26 * via GfxMonitor. 27 */ 28 public class FullscreenRotationTest extends WindowAnimationJankTestBase { 29 private final static int STEP_CNT = 3; 30 31 @Override 32 public void beforeTest() throws Exception { 33 getUiDevice().setOrientationLeft(); 34 Utils.startElementLayout(getInstrumentation(), 100); 35 super.beforeTest(); 36 } 37 38 @Override 39 public void afterTest(Bundle metrics) { 40 Utils.rotateDevice(getInstrumentation(), Utils.ROTATION_MODE_NATURAL); 41 super.afterTest(metrics); 42 } 43 44 @JankTest(expectedFrames=100, defaultIterationCount=2) 45 @GfxMonitor(processName=Utils.PACKAGE) 46 public void testRotation() throws Exception { 47 for (int i = 0; i < STEP_CNT; ++i) { 48 Utils.rotateDevice(getInstrumentation(), 49 Utils.getDeviceRotation(getInstrumentation()) == Utils.ROTATION_MODE_LEFT ? 50 Utils.ROTATION_MODE_RIGHT : Utils.ROTATION_MODE_LEFT); 51 } 52 } 53 } 54