blob: 1b07572fd3f8c1ca0fcf17397d415bdd93196cb8 [file] [log] [blame]
Rahul Ravikumar05336002019-10-14 15:04:32 -07001/*
2 * Copyright (C) 2018 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 */
16package android.app;
17
18import android.content.Context;
19import android.content.res.Resources;
20import android.perftests.utils.BenchmarkState;
21import android.perftests.utils.PerfStatusReporter;
22
23import androidx.test.InstrumentationRegistry;
24import androidx.test.filters.LargeTest;
25
26import org.junit.Before;
27import org.junit.Rule;
28import org.junit.Test;
29
30/**
31 * Benchmarks for {@link android.content.res.Resources.Theme}.
32 */
33@LargeTest
34public class ResourcesThemePerfTest {
35 @Rule
36 public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
37
38 private Resources.Theme mTheme;
39
40 @Before
41 public void setUp() {
42 Context context = InstrumentationRegistry.getTargetContext();
43 mTheme = context.getTheme();
44
45 }
46
47 @Test
48 public void obtainStyledAttributesForViewFromMaterial() {
49 final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
50 while (state.keepRunning()) {
51 mTheme.obtainStyledAttributes(android.R.style.Theme_Material, android.R.styleable.View);
52 }
53 }
54
55}