Seigo Nonaka | f0b5aab | 2016-06-30 18:02:36 +0900 | [diff] [blame] | 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.graphics.perftests; |
| 18 | |
| 19 | import android.graphics.Paint; |
| 20 | import android.perftests.utils.BenchmarkState; |
| 21 | import android.perftests.utils.PerfStatusReporter; |
Riddle Hsu | 1be1dd6 | 2019-09-24 17:54:38 -0600 | [diff] [blame^] | 22 | import android.perftests.utils.PerfTestActivity; |
Seigo Nonaka | f0b5aab | 2016-06-30 18:02:36 +0900 | [diff] [blame] | 23 | |
KOUSHIK PANUGANTI | 412796e | 2018-12-17 14:16:52 -0800 | [diff] [blame] | 24 | import androidx.test.filters.LargeTest; |
| 25 | import androidx.test.rule.ActivityTestRule; |
Seigo Nonaka | f0b5aab | 2016-06-30 18:02:36 +0900 | [diff] [blame] | 26 | |
| 27 | import org.junit.Rule; |
| 28 | import org.junit.Test; |
| 29 | import org.junit.runner.RunWith; |
Seigo Nonaka | f0b5aab | 2016-06-30 18:02:36 +0900 | [diff] [blame] | 30 | import org.junit.runners.Parameterized; |
KOUSHIK PANUGANTI | 412796e | 2018-12-17 14:16:52 -0800 | [diff] [blame] | 31 | import org.junit.runners.Parameterized.Parameters; |
| 32 | |
| 33 | import java.util.Arrays; |
| 34 | import java.util.Collection; |
Seigo Nonaka | f0b5aab | 2016-06-30 18:02:36 +0900 | [diff] [blame] | 35 | |
| 36 | @LargeTest |
| 37 | @RunWith(Parameterized.class) |
| 38 | public 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 Hsu | 1be1dd6 | 2019-09-24 17:54:38 -0600 | [diff] [blame^] | 61 | public ActivityTestRule<PerfTestActivity> mActivityRule = |
| 62 | new ActivityTestRule<>(PerfTestActivity.class); |
Seigo Nonaka | f0b5aab | 2016-06-30 18:02:36 +0900 | [diff] [blame] | 63 | |
| 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 | } |