Home | History | Annotate | Download | only in view
      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.view;
     18 
     19 import android.content.Context;
     20 import android.content.res.Resources;
     21 import android.perftests.utils.BenchmarkState;
     22 import android.perftests.utils.PerfStatusReporter;
     23 import android.support.test.InstrumentationRegistry;
     24 import android.support.test.filters.LargeTest;
     25 import android.widget.FrameLayout;
     26 
     27 import com.android.perftests.core.R;
     28 
     29 import org.junit.Rule;
     30 import org.junit.Test;
     31 
     32 @LargeTest
     33 public class ViewPerfTest {
     34     @Rule
     35     public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
     36 
     37     @Test
     38     public void testSimpleViewInflate() {
     39         final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
     40         final Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
     41         LayoutInflater inflater = LayoutInflater.from(context);
     42         FrameLayout root = new FrameLayout(context);
     43         while (state.keepRunning()) {
     44             inflater.inflate(R.layout.test_simple_view, root, false);
     45         }
     46     }
     47 
     48     @Test
     49     public void testTwelveKeyInflate() {
     50         final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
     51         final Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
     52         LayoutInflater inflater = LayoutInflater.from(context);
     53         FrameLayout root = new FrameLayout(context);
     54         while (state.keepRunning()) {
     55             inflater.inflate(R.layout.twelve_key_entry, root, false);
     56         }
     57     }
     58 }
     59