summaryrefslogtreecommitdiff
path: root/tests/UiBench/src
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2016-06-30 14:55:55 -0700
committerChris Craik <ccraik@google.com>2016-06-30 16:19:52 -0700
commit7ff5cf7375ccd0c7d0736b61ad7e1d96a0b75a47 (patch)
tree8b611253ef060e58acc2cbb5d79692d1cacdd014 /tests/UiBench/src
parent0ede07d4bd59b4a2108fda1cd4ab767cc0058fb8 (diff)
Add InvalidateTreeActivity UiBench case
Change-Id: I9c411c656502d3b73e4fceba4fc084dce28743d1
Diffstat (limited to 'tests/UiBench/src')
-rw-r--r--tests/UiBench/src/com/android/test/uibench/InvalidateActivity.java4
-rw-r--r--tests/UiBench/src/com/android/test/uibench/InvalidateTreeActivity.java79
2 files changed, 81 insertions, 2 deletions
diff --git a/tests/UiBench/src/com/android/test/uibench/InvalidateActivity.java b/tests/UiBench/src/com/android/test/uibench/InvalidateActivity.java
index 93d67a60515f..81d03ffee0ed 100644
--- a/tests/UiBench/src/com/android/test/uibench/InvalidateActivity.java
+++ b/tests/UiBench/src/com/android/test/uibench/InvalidateActivity.java
@@ -31,7 +31,7 @@ import android.view.ViewGroup;
* Tests invalidation performance by invalidating a large number of easily rendered views,
*/
public class InvalidateActivity extends AppCompatActivity {
- public static class ColorView extends View {
+ private static class ColorView extends View {
@ColorInt
public int mColor;
@@ -50,7 +50,7 @@ public class InvalidateActivity extends AppCompatActivity {
}
}
- ColorView[][] mColorViews;
+ private ColorView[][] mColorViews;
@SuppressWarnings("unused")
public void setColorValue(int colorValue) {
diff --git a/tests/UiBench/src/com/android/test/uibench/InvalidateTreeActivity.java b/tests/UiBench/src/com/android/test/uibench/InvalidateTreeActivity.java
new file mode 100644
index 000000000000..b800c26bfc60
--- /dev/null
+++ b/tests/UiBench/src/com/android/test/uibench/InvalidateTreeActivity.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.test.uibench;
+
+import android.animation.ObjectAnimator;
+import android.animation.ValueAnimator;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+
+import java.util.ArrayList;
+
+/**
+ * Tests invalidation/record performance by invalidating a large number of easily rendered
+ * nested views.
+ */
+public class InvalidateTreeActivity extends AppCompatActivity {
+ private final ArrayList<LinearLayout> mLayouts = new ArrayList<>();
+
+ private int mColorToggle = 0;
+
+ private void createQuadTree(LinearLayout parent, int remainingDepth) {
+ mLayouts.add(parent);
+ if (remainingDepth <= 0) {
+ mColorToggle = (mColorToggle + 1) % 4;
+ parent.setBackgroundColor((mColorToggle < 2) ? Color.RED : Color.BLUE);
+ return;
+ }
+
+ boolean vertical = remainingDepth % 2 == 0;
+ parent.setOrientation(vertical ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL);
+
+ for (int i = 0; i < 2; i++) {
+ LinearLayout child = new LinearLayout(this);
+ // vertical: match parent in x axis, horizontal: y axis.
+ parent.addView(child, new LinearLayout.LayoutParams(
+ (vertical ? ViewGroup.LayoutParams.MATCH_PARENT : 0),
+ (vertical ? 0 : ViewGroup.LayoutParams.MATCH_PARENT),
+ 1.0f));
+
+ createQuadTree(child, remainingDepth - 1);
+ }
+ }
+
+ @SuppressWarnings("unused")
+ public void setIgnoredValue(int ignoredValue) {
+ for (int i = 0; i < mLayouts.size(); i++) {
+ mLayouts.get(i).invalidate();
+ }
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ LinearLayout root = new LinearLayout(this);
+ createQuadTree(root, 8);
+ setContentView(root);
+
+ ObjectAnimator animator = ObjectAnimator.ofInt(this, "ignoredValue", 0, 1000);
+ animator.setRepeatMode(ValueAnimator.REVERSE);
+ animator.setRepeatCount(ValueAnimator.INFINITE);
+ animator.start();
+ }
+}