KeyboardLayoutSetSubtypesCountTests.java revision f64a9d8fd6d764adc002e854246385e682821c2c
1/* 2 * Copyright (C) 2014 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 17package com.android.inputmethod.keyboard; 18 19import android.test.suitebuilder.annotation.SmallTest; 20import android.view.inputmethod.InputMethodSubtype; 21 22import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; 23 24import java.util.ArrayList; 25 26@SmallTest 27public class KeyboardLayoutSetSubtypesCountTests extends KeyboardLayoutSetTestsBase { 28 private static final int NUMBER_OF_SUBTYPES = 66; 29 private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 42; 30 private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2; 31 32 private static String toString(final ArrayList<InputMethodSubtype> subtypeList) { 33 final StringBuilder sb = new StringBuilder(); 34 for (int index = 0; index < subtypeList.size(); index++) { 35 final InputMethodSubtype subtype = subtypeList.get(index); 36 sb.append(index + ": "); 37 sb.append(SubtypeLocaleUtils.getSubtypeNameForLogging(subtype)); 38 sb.append("\n"); 39 } 40 return sb.toString(); 41 } 42 43 public final void testAllSubtypesCount() { 44 final ArrayList<InputMethodSubtype> allSubtypesList = getAllSubtypesList(); 45 assertEquals(toString(allSubtypesList), NUMBER_OF_SUBTYPES, allSubtypesList.size()); 46 } 47 48 public final void testAsciiCapableSubtypesCount() { 49 final ArrayList<InputMethodSubtype> asciiCapableSubtypesList = 50 getAsciiCapableSubtypesList(); 51 assertEquals(toString(asciiCapableSubtypesList), 52 NUMBER_OF_ASCII_CAPABLE_SUBTYPES, asciiCapableSubtypesList.size()); 53 } 54 55 public final void testAdditionalSubtypesCount() { 56 final ArrayList<InputMethodSubtype> additionalSubtypesList = getAdditionalSubtypesList(); 57 assertEquals(toString(additionalSubtypesList), 58 NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES, additionalSubtypesList.size()); 59 } 60} 61