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.action;
18 
19 import android.view.inputmethod.InputMethodSubtype;
20 
21 import com.android.inputmethod.keyboard.KeyboardTheme;
22 import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
23 
24 import java.util.ArrayList;
25 import java.util.Locale;
26 
27 abstract class KlpActionTestsBase extends ActionTestsBase {
28     // Filter a subtype whose name should be displayed using {@link Locale#ROOT}, such like
29     // Hinglish (hi_ZZ) and Serbian-Latn (sr_ZZ).
30     static final SubtypeFilter SUBTYPE_FILTER_NAME_IN_BASE_LOCALE = new SubtypeFilter() {
31         @Override
32         public boolean accept(final InputMethodSubtype subtype) {
33             return Locale.ROOT.equals(
34                     SubtypeLocaleUtils.getDisplayLocaleOfSubtypeLocale(subtype.getLocale()));
35         }
36     };
37 
38     protected ArrayList<InputMethodSubtype> mSubtypesWhoseNameIsDisplayedInItsLocale;
39 
40     @Override
setUp()41     protected void setUp() throws Exception {
42         super.setUp();
43         mSubtypesWhoseNameIsDisplayedInItsLocale = getSubtypesFilteredBy(new SubtypeFilter() {
44             @Override
45             public boolean accept(final InputMethodSubtype subtype) {
46                 return !SUBTYPE_FILTER_NAME_IN_BASE_LOCALE.accept(subtype);
47             }
48         });
49     }
50 
51     @Override
getKeyboardThemeForTests()52     protected int getKeyboardThemeForTests() {
53         return KeyboardTheme.THEME_ID_KLP;
54     }
55 }
56