1 /*
2  * Copyright 2019 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 androidx.appcompat.benchmark
18 
19 import android.content.Context
20 import android.view.LayoutInflater
21 import android.widget.FrameLayout
22 import androidx.appcompat.app.AppCompatActivity
23 import androidx.appcompat.benchmark.test.R
24 import androidx.benchmark.junit4.BenchmarkRule
25 import androidx.benchmark.junit4.measureRepeated
26 import androidx.test.ext.junit.runners.AndroidJUnit4
27 import androidx.test.filters.LargeTest
28 import org.junit.Rule
29 import org.junit.Test
30 import org.junit.runner.RunWith
31 
32 @LargeTest
33 @RunWith(AndroidJUnit4::class)
34 class ViewInflationBenchmark {
35     @get:Rule val benchmarkRule = BenchmarkRule()
36 
37     @Suppress("DEPRECATION")
38     @get:Rule
39     val activityRule = androidx.test.rule.ActivityTestRule(AppCompatActivity::class.java)
40 
41     @Test
testTwelveKeyInflatenull42     fun testTwelveKeyInflate() {
43         val context: Context = activityRule.activity
44         val inflater = LayoutInflater.from(context)
45         val root = FrameLayout(context)
46         benchmarkRule.measureRepeated { inflater.inflate(R.layout.twelve_key_entry, root, false) }
47     }
48 }
49