Debian Codegraph @

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

raw symbols SCIP
1 /*
2 * Copyright (C) 2016 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.perftests.utils.BenchmarkState;
20 import android.perftests.utils.PerfStatusReporter;
21 import android.perftests.utils.PerfTestActivity;
22
23 import androidx.test.filters.LargeTest;
24 import androidx.test.rule.ActivityTestRule;
25
26 import org.junit.Rule;
27 import org.junit.Test;
28 import org.junit.runner.RunWith;
29 import org.junit.runners.Parameterized;
30 import org.junit.runners.Parameterized.Parameters;
31
32 import java.util.Arrays;
33 import java.util.Collection;
34 import java.util.Locale;
35
36 @LargeTest
37 @RunWith(Parameterized.class)
38 public class TextViewSetTextLocalePerfTest {
39 @Parameters(name = "{0}")
40 public static Collection locales() {
41 return Arrays.asList(new Object[][] {
42 { "SameLocale", "en-US", "en-US" },
43 { "DifferentLocale", "en-US", "ja-JP"}
44 });
45 }
46
47 private String mMetricKey;
48 private Locale mFirstLocale;
49 private Locale mSecondLocale;
50
51 public TextViewSetTextLocalePerfTest(
52 String metricKey, String firstLocale, String secondLocale) {
53 mMetricKey = metricKey;
54 mFirstLocale = Locale.forLanguageTag(firstLocale);
55 mSecondLocale = Locale.forLanguageTag(secondLocale);
56 }
57
58 @Rule
59 public ActivityTestRule<PerfTestActivity> mActivityRule =
60 new ActivityTestRule<>(PerfTestActivity.class);
61
62 @Rule
63 public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
64
65 @Test
66 public void testSetTextLocale() {
67 TextView textView = new TextView(mActivityRule.getActivity());
68
69 BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
70
71 while (state.keepRunning()) {
72 textView.setTextLocale(mFirstLocale);
73 textView.setTextLocale(mSecondLocale);
74 }
75 }
76 }