12ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka/* 22ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka * Copyright (C) 2017 The Android Open Source Project 32ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka * 42ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka * Licensed under the Apache License, Version 2.0 (the "License"); 52ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka * you may not use this file except in compliance with the License. 62ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka * You may obtain a copy of the License at 72ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka * 82ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka * http://www.apache.org/licenses/LICENSE-2.0 92ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka * 102ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka * Unless required by applicable law or agreed to in writing, software 112ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka * distributed under the License is distributed on an "AS IS" BASIS, 122ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 132ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka * See the License for the specific language governing permissions and 142ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka * limitations under the License 152ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka */ 162ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka 172ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakapackage android.widget; 182ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka 192ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport android.content.Context; 202ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport android.perftests.utils.BenchmarkState; 212ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport android.perftests.utils.PerfStatusReporter; 222ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport android.support.test.InstrumentationRegistry; 232ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport android.support.test.filters.LargeTest; 242ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport android.support.test.runner.AndroidJUnit4; 252ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport android.view.LayoutInflater; 262ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka 272ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport com.android.perftests.core.R; 282ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka 292ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport java.util.Collection; 302ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport java.util.Arrays; 312ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka 322ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport org.junit.Test; 332ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport org.junit.Rule; 342ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport org.junit.runners.Parameterized; 352ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport org.junit.runners.Parameterized.Parameters; 362ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport org.junit.runner.RunWith; 372ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka 382ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakaimport static org.junit.Assert.assertTrue; 392ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka 402ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka@LargeTest 412ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka@RunWith(Parameterized.class) 422ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonakapublic class TextViewFontFamilyLayoutPerfTest { 432ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka @Parameters(name = "{0}") 442ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka public static Collection layouts() { 452ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka return Arrays.asList(new Object[][] { 462ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka { "String fontFamily attribute", R.layout.test_textview_font_family_string}, 472ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka { "File fontFamily attribute", R.layout.test_textview_font_family_file}, 482ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka { "XML fontFamily attribute", R.layout.test_textview_font_family_xml}, 492ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka }); 502ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka } 512ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka 522ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka private int mLayoutId; 532ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka 542ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka public TextViewFontFamilyLayoutPerfTest(String key, int layoutId) { 552ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka mLayoutId = layoutId; 562ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka } 572ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka 582ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka @Rule 592ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); 602ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka 612ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka @Test 622ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka public void testConstruction() throws Throwable { 632ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka final Context context = InstrumentationRegistry.getTargetContext(); 642ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); 652ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka final LayoutInflater inflator = 662ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 672ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka 682ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka while (state.keepRunning()) { 692ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka inflator.inflate(mLayoutId, null, false); 702ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka } 712ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka } 722ea169a2ecbb7e589fcef78cb1486d007a8fb867Seigo Nonaka} 73