KeyboardLayoutSetSubtypesCountTests.java revision 25906373ffe1b0e3e99b7412e9fd2a54f5d73345
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 = 78;
29    private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 45;
30    private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2;
31
32    @Override
33    protected int getKeyboardThemeForTests() {
34        return KeyboardTheme.THEME_ID_KLP;
35    }
36
37    private static String toString(final ArrayList<InputMethodSubtype> subtypeList) {
38        final StringBuilder sb = new StringBuilder();
39        for (int index = 0; index < subtypeList.size(); index++) {
40            final InputMethodSubtype subtype = subtypeList.get(index);
41            sb.append(index + ": ");
42            sb.append(SubtypeLocaleUtils.getSubtypeNameForLogging(subtype));
43            sb.append("\n");
44        }
45        return sb.toString();
46    }
47
48    public final void testAllSubtypesCount() {
49        final ArrayList<InputMethodSubtype> allSubtypesList = getAllSubtypesList();
50        assertEquals(toString(allSubtypesList), NUMBER_OF_SUBTYPES, allSubtypesList.size());
51    }
52
53    public final void testAsciiCapableSubtypesCount() {
54        final ArrayList<InputMethodSubtype> asciiCapableSubtypesList =
55                getAsciiCapableSubtypesList();
56        assertEquals(toString(asciiCapableSubtypesList),
57                NUMBER_OF_ASCII_CAPABLE_SUBTYPES, asciiCapableSubtypesList.size());
58    }
59
60    public final void testAdditionalSubtypesCount() {
61        final ArrayList<InputMethodSubtype> additionalSubtypesList = getAdditionalSubtypesList();
62        assertEquals(toString(additionalSubtypesList),
63                NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES, additionalSubtypesList.size());
64    }
65}
66