blob: b9c7af46c67c3d59f5b2d6074266c202c84d92ed [file] [log] [blame]
Seigo Nonakaf0b5aab2016-06-30 18:02:36 +09001/*
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
17package android.graphics.perftests;
18
19import android.graphics.Paint;
20import android.perftests.utils.BenchmarkState;
21import android.perftests.utils.PerfStatusReporter;
Riddle Hsu1be1dd62019-09-24 17:54:38 -060022import android.perftests.utils.PerfTestActivity;
Seigo Nonakaf0b5aab2016-06-30 18:02:36 +090023
KOUSHIK PANUGANTI412796e2018-12-17 14:16:52 -080024import androidx.test.filters.LargeTest;
25import androidx.test.rule.ActivityTestRule;
Seigo Nonakaf0b5aab2016-06-30 18:02:36 +090026
27import org.junit.Rule;
28import org.junit.Test;
29import org.junit.runner.RunWith;
Seigo Nonakaf0b5aab2016-06-30 18:02:36 +090030import org.junit.runners.Parameterized;
KOUSHIK PANUGANTI412796e2018-12-17 14:16:52 -080031import org.junit.runners.Parameterized.Parameters;
32
33import java.util.Arrays;
34import java.util.Collection;
Seigo Nonakaf0b5aab2016-06-30 18:02:36 +090035
36@LargeTest
37@RunWith(Parameterized.class)
38public class PaintHasGlyphPerfTest {
39 @Parameters(name = "{0}")
40 public static Collection glyphStrings() {
41 return Arrays.asList(new Object[][] {
42 { "Latin", "A" },
43 { "Ligature", "fi" },
44 { "SurrogatePair", "\uD83D\uDE00" }, // U+1F600
45 { "Flags", "\uD83C\uDDFA\uD83C\uDDF8" }, // US
46 { "Ideograph_VariationSelector", "\u3402\uDB40\uDD00" }, // U+3402 U+E0100
47 { "Emoji_VariationSelector", "\u00A9\uFE0F" },
48 { "EmojiSequence",
49 // U+1F468 U+200D U+2764 U+FE0F U+200D U+1F48B U+200D U+1F468
50 "\uD83D\uDC68\u200D\u2764\uFE0F\u200D\uD83D\uDC8B\u200D\uD83D\uDC68" },
51 });
52 }
53
54 private final String mQuery;
55
56 public PaintHasGlyphPerfTest(String metricKey, String query) {
57 mQuery = query;
58 }
59
60 @Rule
Riddle Hsu1be1dd62019-09-24 17:54:38 -060061 public ActivityTestRule<PerfTestActivity> mActivityRule =
62 new ActivityTestRule<>(PerfTestActivity.class);
Seigo Nonakaf0b5aab2016-06-30 18:02:36 +090063
64 @Rule
65 public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
66
67 @Test
68 public void testHasGlyph() {
69 Paint paint = new Paint();
70 BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
71
72 while (state.keepRunning()) {
73 paint.hasGlyph(mQuery);
74 }
75 }
76}