1 /* 2 * Copyright (C) 2019 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 package android.gameperformance; 17 18 import android.annotation.NonNull; 19 20 /** 21 * Tests that verifies how many UI controls can be handled to keep FPS close to device refresh rate. 22 * As a test UI control ImageView with an infinite animation is chosen. The animation has refresh 23 * rate ~67Hz that forces all devices to refresh UI at highest possible rate. 24 */ 25 public class ControlsTest extends BaseTest { ControlsTest(@onNull GamePerformanceActivity activity)26 public ControlsTest(@NonNull GamePerformanceActivity activity) { 27 super(activity); 28 } 29 30 @NonNull getView()31 public CustomControlView getView() { 32 return getActivity().getControlView(); 33 } 34 35 @Override initProbePass(int probe)36 protected void initProbePass(int probe) { 37 try { 38 getActivity().attachControlView(); 39 } catch (InterruptedException e) { 40 Thread.currentThread().interrupt(); 41 return; 42 } 43 initUnits(probe * getUnitScale()); 44 } 45 46 @Override freeProbePass()47 protected void freeProbePass() { 48 } 49 50 @Override getName()51 public String getName() { 52 return "control_count"; 53 } 54 55 @Override getUnitName()56 public String getUnitName() { 57 return "controls"; 58 } 59 60 @Override getUnitScale()61 public double getUnitScale() { 62 return 5.0; 63 } 64 65 @Override initUnits(double controlCount)66 public void initUnits(double controlCount) { 67 try { 68 getView().createControls(getActivity(), (int)Math.round(controlCount)); 69 } catch (InterruptedException e) { 70 Thread.currentThread().interrupt(); 71 } 72 } 73 }