Rahul Ravikumar | 0533600 | 2019-10-14 15:04:32 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package android.app; |
| 17 | |
| 18 | import android.content.Context; |
| 19 | import android.content.res.Resources; |
| 20 | import android.perftests.utils.BenchmarkState; |
| 21 | import android.perftests.utils.PerfStatusReporter; |
| 22 | |
| 23 | import androidx.test.InstrumentationRegistry; |
| 24 | import androidx.test.filters.LargeTest; |
| 25 | |
| 26 | import org.junit.Before; |
| 27 | import org.junit.Rule; |
| 28 | import org.junit.Test; |
| 29 | |
| 30 | /** |
| 31 | * Benchmarks for {@link android.content.res.Resources.Theme}. |
| 32 | */ |
| 33 | @LargeTest |
| 34 | public 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 | } |