summaryrefslogtreecommitdiff
path: root/apct-tests
diff options
context:
space:
mode:
authorAurimas Liutikas <aurimas@google.com>2018-08-23 15:09:04 -0700
committerAurimas Liutikas <aurimas@google.com>2018-08-23 15:10:27 -0700
commit64ec5b84b996370dbe1c0893dc124267d2ef5edd (patch)
treef0fe2ac388e157055622d749a447bbb682f06ca6 /apct-tests
parentd5796dd4f1cce3860241ab179e0bd07fbaf19864 (diff)
Add a simple benchmark for getting view attributes from Theme_Material.
Test: atest CorePerfTests:ResourcesThemePerfTest Change-Id: I228273c8b83ebfee73c478f72ceec42d3f81a53b
Diffstat (limited to 'apct-tests')
-rw-r--r--apct-tests/perftests/core/src/android/app/ResourcesThemePerfTest.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/apct-tests/perftests/core/src/android/app/ResourcesThemePerfTest.java b/apct-tests/perftests/core/src/android/app/ResourcesThemePerfTest.java
new file mode 100644
index 000000000000..bb0627e562b4
--- /dev/null
+++ b/apct-tests/perftests/core/src/android/app/ResourcesThemePerfTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2018 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 android.app;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.perftests.utils.BenchmarkState;
+import android.perftests.utils.PerfStatusReporter;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.LargeTest;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * Benchmarks for {@link android.content.res.Resources.Theme}.
+ */
+@LargeTest
+public class ResourcesThemePerfTest {
+ @Rule
+ public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
+
+ private Resources.Theme mTheme;
+
+ @Before
+ public void setUp() {
+ Context context = InstrumentationRegistry.getTargetContext();
+ mTheme = context.getTheme();
+
+ }
+
+ @Test
+ public void obtainStyledAttributesForViewFromMaterial() {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ while (state.keepRunning()) {
+ mTheme.obtainStyledAttributes(android.R.style.Theme_Material, android.R.styleable.View);
+ }
+ }
+
+}