Debian Codegraph @

apct-tests/perftests/core/src/android/widget/TextViewFontFamilyLayoutPerfTest.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2017 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
17 package android.widget;
18
19 import android.content.Context;
20 import android.perftests.utils.BenchmarkState;
21 import android.perftests.utils.PerfStatusReporter;
22 import android.view.LayoutInflater;
23
24 import androidx.test.InstrumentationRegistry;
25 import androidx.test.filters.LargeTest;
26
27 import com.android.perftests.core.R;
28
29 import org.junit.Rule;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 import org.junit.runners.Parameterized;
33 import org.junit.runners.Parameterized.Parameters;
34
35 import java.util.Arrays;
36 import java.util.Collection;
37
38 @LargeTest
39 @RunWith(Parameterized.class)
40 public class TextViewFontFamilyLayoutPerfTest {
41 @Parameters(name = "{0}")
42 public static Collection layouts() {
43 return Arrays.asList(new Object[][] {
44 { "String fontFamily attribute", R.layout.test_textview_font_family_string},
45 { "File fontFamily attribute", R.layout.test_textview_font_family_file},
46 { "XML fontFamily attribute", R.layout.test_textview_font_family_xml},
47 });
48 }
49
50 private int mLayoutId;
51
52 public TextViewFontFamilyLayoutPerfTest(String key, int layoutId) {
53 mLayoutId = layoutId;
54 }
55
56 @Rule
57 public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
58
59 @Test
60 public void testConstruction() throws Throwable {
61 final Context context = InstrumentationRegistry.getTargetContext();
62 final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
63 final LayoutInflater inflator =
64 (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
65
66 while (state.keepRunning()) {
67 inflator.inflate(mLayoutId, null, false);
68 }
69 }
70 }