| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 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 |
} |