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