Separate flaky unit test from KeyboardLayoutSetTestsBase
Move the flaky unit test to KeyboardLayoutSetSubtypesCountTests. Bug: 13291370 Bug: 13017434 Change-Id: I2144be4cc6b8215b895c45f47a5190fdeaa806f9main
parent
ddc21f5bd1
commit
73b3b81149
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.inputmethod.keyboard;
|
||||||
|
|
||||||
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
|
|
||||||
|
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
|
public class KeyboardLayoutSetSubtypesCountTests extends KeyboardLayoutSetTestsBase {
|
||||||
|
private static final int NUMBER_OF_SUBTYPES = 63;
|
||||||
|
private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 40;
|
||||||
|
private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2;
|
||||||
|
|
||||||
|
private static String toString(final ArrayList<InputMethodSubtype> subtypeList) {
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
for (int index = 0; index < subtypeList.size(); index++) {
|
||||||
|
final InputMethodSubtype subtype = subtypeList.get(index);
|
||||||
|
sb.append(index + ": ");
|
||||||
|
sb.append(SubtypeLocaleUtils.getSubtypeNameForLogging(subtype));
|
||||||
|
sb.append("\n");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void testAllSubtypesCount() {
|
||||||
|
final ArrayList<InputMethodSubtype> allSubtypesList = getAllSubtypesList();
|
||||||
|
assertEquals(toString(allSubtypesList), NUMBER_OF_SUBTYPES, allSubtypesList.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void testAsciiCapableSubtypesCount() {
|
||||||
|
final ArrayList<InputMethodSubtype> asciiCapableSubtypesList =
|
||||||
|
getAsciiCapableSubtypesList();
|
||||||
|
assertEquals(toString(asciiCapableSubtypesList),
|
||||||
|
NUMBER_OF_ASCII_CAPABLE_SUBTYPES, asciiCapableSubtypesList.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void testAdditionalSubtypesCount() {
|
||||||
|
final ArrayList<InputMethodSubtype> additionalSubtypesList = getAdditionalSubtypesList();
|
||||||
|
assertEquals(toString(additionalSubtypesList),
|
||||||
|
NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES, additionalSubtypesList.size());
|
||||||
|
}
|
||||||
|
}
|
|
@ -41,10 +41,6 @@ import java.util.Locale;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class KeyboardLayoutSetTestsBase extends AndroidTestCase {
|
public class KeyboardLayoutSetTestsBase extends AndroidTestCase {
|
||||||
private static final int NUMBER_OF_SUBTYPES = 63;
|
|
||||||
private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 40;
|
|
||||||
private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2;
|
|
||||||
|
|
||||||
private static final KeyboardTheme DEFAULT_KEYBOARD_THEME =
|
private static final KeyboardTheme DEFAULT_KEYBOARD_THEME =
|
||||||
KeyboardSwitcher.KEYBOARD_THEMES[KeyboardSwitcher.THEME_INDEX_DEFAULT];
|
KeyboardSwitcher.KEYBOARD_THEMES[KeyboardSwitcher.THEME_INDEX_DEFAULT];
|
||||||
|
|
||||||
|
@ -82,37 +78,23 @@ public class KeyboardLayoutSetTestsBase extends AndroidTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected final ArrayList<InputMethodSubtype> getAllSubtypesList() {
|
||||||
|
return mAllSubtypesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final ArrayList<InputMethodSubtype> getAsciiCapableSubtypesList() {
|
||||||
|
return mAsciiCapableSubtypesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final ArrayList<InputMethodSubtype> getAdditionalSubtypesList() {
|
||||||
|
return mAdditionalSubtypesList;
|
||||||
|
}
|
||||||
|
|
||||||
protected final boolean isPhone() {
|
protected final boolean isPhone() {
|
||||||
return mScreenMetrics == Constants.SCREEN_METRICS_SMALL_PHONE
|
return mScreenMetrics == Constants.SCREEN_METRICS_SMALL_PHONE
|
||||||
|| mScreenMetrics == Constants.SCREEN_METRICS_LARGE_PHONE;
|
|| mScreenMetrics == Constants.SCREEN_METRICS_LARGE_PHONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String toString(final ArrayList<InputMethodSubtype> subtypeList) {
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
|
||||||
for (int index = 0; index < subtypeList.size(); index++) {
|
|
||||||
final InputMethodSubtype subtype = subtypeList.get(index);
|
|
||||||
sb.append(index + ": ");
|
|
||||||
sb.append(SubtypeLocaleUtils.getSubtypeNameForLogging(subtype));
|
|
||||||
sb.append("\n");
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void testAllSubtypesCount() {
|
|
||||||
assertEquals(toString(mAllSubtypesList),
|
|
||||||
NUMBER_OF_SUBTYPES, mAllSubtypesList.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void testAsciiCapableSubtypesCount() {
|
|
||||||
assertEquals(toString(mAsciiCapableSubtypesList),
|
|
||||||
NUMBER_OF_ASCII_CAPABLE_SUBTYPES, mAsciiCapableSubtypesList.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void testAdditionalSubtypesCount() {
|
|
||||||
assertEquals(toString(mAdditionalSubtypesList),
|
|
||||||
NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES, mAdditionalSubtypesList.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final InputMethodSubtype getSubtype(final Locale locale,
|
protected final InputMethodSubtype getSubtype(final Locale locale,
|
||||||
final String keyboardLayout) {
|
final String keyboardLayout) {
|
||||||
for (final InputMethodSubtype subtype : mAllSubtypesList) {
|
for (final InputMethodSubtype subtype : mAllSubtypesList) {
|
||||||
|
|
Loading…
Reference in New Issue