1 /* 2 * Copyright (C) 2020 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.inputmethod; 18 19 import static android.perftests.utils.PerfTestActivity.INTENT_EXTRA_ADD_EDIT_TEXT; 20 21 import android.content.Intent; 22 import android.perftests.utils.PerfTestActivity; 23 import android.perftests.utils.WindowPerfTestBase; 24 25 public class ImePerfTestBase extends WindowPerfTestBase { 26 static final long TIMEOUT_1_S_IN_MS = 1 * 1000L; 27 28 /** Provides an activity that contains an edit text view.*/ 29 static class PerfTestActivityRule extends PerfTestActivityRuleBase { 30 31 @Override launchActivity(Intent intent)32 public PerfTestActivity launchActivity(Intent intent) { 33 intent.putExtra(INTENT_EXTRA_ADD_EDIT_TEXT, true); 34 return super.launchActivity(intent); 35 } 36 } 37 buildArray(String[].... arrays)38 static String[] buildArray(String[]... arrays) { 39 int length = 0; 40 for (String[] array : arrays) { 41 length += array.length; 42 } 43 String[] newArray = new String[length]; 44 int offset = 0; 45 for (String[] array : arrays) { 46 System.arraycopy(array, 0, newArray, offset, array.length); 47 offset += array.length; 48 } 49 return newArray; 50 } 51 } 52