Home | History | Annotate | Download | only in tests
      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 
     17 package com.android.inputmethod.keyboard.layout.tests;
     18 
     19 import android.test.suitebuilder.annotation.SmallTest;
     20 import android.view.inputmethod.InputMethodSubtype;
     21 
     22 import com.android.inputmethod.keyboard.KeyboardLayoutSetTestsBase;
     23 import com.android.inputmethod.keyboard.KeyboardTheme;
     24 import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
     25 
     26 import java.util.ArrayList;
     27 
     28 @SmallTest
     29 public class KeyboardLayoutSetSubtypesCountTests extends KeyboardLayoutSetTestsBase {
     30     private static final int NUMBER_OF_SUBTYPES = 81;
     31     private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 49;
     32     private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2;
     33 
     34     @Override
     35     protected int getKeyboardThemeForTests() {
     36         return KeyboardTheme.THEME_ID_KLP;
     37     }
     38 
     39     private static String toString(final ArrayList<InputMethodSubtype> subtypeList) {
     40         final StringBuilder sb = new StringBuilder();
     41         for (int index = 0; index < subtypeList.size(); index++) {
     42             final InputMethodSubtype subtype = subtypeList.get(index);
     43             sb.append(index + ": ");
     44             sb.append(SubtypeLocaleUtils.getSubtypeNameForLogging(subtype));
     45             sb.append("\n");
     46         }
     47         return sb.toString();
     48     }
     49 
     50     public final void testAllSubtypesCount() {
     51         final ArrayList<InputMethodSubtype> allSubtypesList = getAllSubtypesList();
     52         assertEquals(toString(allSubtypesList), NUMBER_OF_SUBTYPES, allSubtypesList.size());
     53     }
     54 
     55     public final void testAsciiCapableSubtypesCount() {
     56         final ArrayList<InputMethodSubtype> asciiCapableSubtypesList =
     57                 getSubtypesFilteredBy(FILTER_IS_ASCII_CAPABLE);
     58         assertEquals(toString(asciiCapableSubtypesList),
     59                 NUMBER_OF_ASCII_CAPABLE_SUBTYPES, asciiCapableSubtypesList.size());
     60     }
     61 
     62     public final void testAdditionalSubtypesCount() {
     63         final ArrayList<InputMethodSubtype> additionalSubtypesList =
     64                 getSubtypesFilteredBy(FILTER_IS_ADDITIONAL_SUBTYPE);
     65         assertEquals(toString(additionalSubtypesList),
     66                 NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES, additionalSubtypesList.size());
     67     }
     68 }
     69