Migrate to Android Testing Support Lib (part 1/N)
This CL converts tests under com.android.inputmethod.latin.utils to Android Testing Support Library. Bug: 110805255 Test: verified as follows. No new test failures. tapas adb LatinIME LatinIMETests arm64 userdebug && \ DISABLE_PROGUARD=true make -j LatinIME && \ adb install -r $OUT/system/app/LatinIME/LatinIME.apk && \ atest LatinIMETests:com.android.inputmethod.latin.utils Change-Id: I5cc2ddbc4116003ab6407432ab521b6b560052aemain
parent
2802250415
commit
9c49581eeb
|
@ -22,19 +22,28 @@ import static com.android.inputmethod.latin.common.Constants.Subtype.ExtraValue.
|
||||||
import static com.android.inputmethod.latin.common.Constants.Subtype.ExtraValue.IS_ADDITIONAL_SUBTYPE;
|
import static com.android.inputmethod.latin.common.Constants.Subtype.ExtraValue.IS_ADDITIONAL_SUBTYPE;
|
||||||
import static com.android.inputmethod.latin.common.Constants.Subtype.ExtraValue.KEYBOARD_LAYOUT_SET;
|
import static com.android.inputmethod.latin.common.Constants.Subtype.ExtraValue.KEYBOARD_LAYOUT_SET;
|
||||||
import static com.android.inputmethod.latin.common.Constants.Subtype.ExtraValue.UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME;
|
import static com.android.inputmethod.latin.common.Constants.Subtype.ExtraValue.UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.test.AndroidTestCase;
|
import android.support.test.InstrumentationRegistry;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.support.test.filters.SmallTest;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
|
|
||||||
import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
|
import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class AdditionalSubtypeUtilsTests extends AndroidTestCase {
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class AdditionalSubtypeUtilsTests {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Predictable subtype ID for en_US dvorak layout. This is actually a hash code calculated as
|
* Predictable subtype ID for en_US dvorak layout. This is actually a hash code calculated as
|
||||||
|
@ -98,10 +107,9 @@ public class AdditionalSubtypeUtilsTests extends AndroidTestCase {
|
||||||
",EmojiCapable" +
|
",EmojiCapable" +
|
||||||
",isAdditionalSubtype";
|
",isAdditionalSubtype";
|
||||||
|
|
||||||
@Override
|
@Before
|
||||||
protected void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
final Context context = InstrumentationRegistry.getTargetContext();
|
||||||
final Context context = getContext();
|
|
||||||
SubtypeLocaleUtils.init(context);
|
SubtypeLocaleUtils.init(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,6 +157,7 @@ public class AdditionalSubtypeUtilsTests extends AndroidTestCase {
|
||||||
assertEquals(SUBTYPE_ID_ZZ_AZERTY, subtype.hashCode());
|
assertEquals(SUBTYPE_ID_ZZ_AZERTY, subtype.hashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testRestorable() {
|
public void testRestorable() {
|
||||||
final InputMethodSubtype EN_US_DVORAK =
|
final InputMethodSubtype EN_US_DVORAK =
|
||||||
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||||
|
|
|
@ -16,12 +16,18 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.utils;
|
package com.android.inputmethod.latin.utils;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import static org.junit.Assert.assertEquals;
|
||||||
import android.test.suitebuilder.annotation.MediumTest;
|
|
||||||
|
import android.support.test.filters.MediumTest;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@MediumTest
|
@MediumTest
|
||||||
public class AsyncResultHolderTests extends AndroidTestCase {
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class AsyncResultHolderTests {
|
||||||
static final String TAG = AsyncResultHolderTests.class.getSimpleName();
|
static final String TAG = AsyncResultHolderTests.class.getSimpleName();
|
||||||
|
|
||||||
private static final int TIMEOUT_IN_MILLISECONDS = 500;
|
private static final int TIMEOUT_IN_MILLISECONDS = 500;
|
||||||
|
@ -44,12 +50,14 @@ public class AsyncResultHolderTests extends AndroidTestCase {
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetWithoutSet() {
|
public void testGetWithoutSet() {
|
||||||
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
|
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
|
||||||
final int resultValue = holder.get(DEFAULT_VALUE, TIMEOUT_IN_MILLISECONDS);
|
final int resultValue = holder.get(DEFAULT_VALUE, TIMEOUT_IN_MILLISECONDS);
|
||||||
assertEquals(DEFAULT_VALUE, resultValue);
|
assertEquals(DEFAULT_VALUE, resultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetBeforeSet() {
|
public void testGetBeforeSet() {
|
||||||
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
|
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
|
||||||
setAfterGivenTime(holder, SET_VALUE, TIMEOUT_IN_MILLISECONDS + MARGIN_IN_MILLISECONDS);
|
setAfterGivenTime(holder, SET_VALUE, TIMEOUT_IN_MILLISECONDS + MARGIN_IN_MILLISECONDS);
|
||||||
|
@ -57,6 +65,7 @@ public class AsyncResultHolderTests extends AndroidTestCase {
|
||||||
assertEquals(DEFAULT_VALUE, resultValue);
|
assertEquals(DEFAULT_VALUE, resultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetAfterSet() {
|
public void testGetAfterSet() {
|
||||||
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
|
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
|
||||||
holder.set(SET_VALUE);
|
holder.set(SET_VALUE);
|
||||||
|
@ -64,6 +73,7 @@ public class AsyncResultHolderTests extends AndroidTestCase {
|
||||||
assertEquals(SET_VALUE, resultValue);
|
assertEquals(SET_VALUE, resultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetBeforeTimeout() {
|
public void testGetBeforeTimeout() {
|
||||||
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
|
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
|
||||||
setAfterGivenTime(holder, SET_VALUE, TIMEOUT_IN_MILLISECONDS - MARGIN_IN_MILLISECONDS);
|
setAfterGivenTime(holder, SET_VALUE, TIMEOUT_IN_MILLISECONDS - MARGIN_IN_MILLISECONDS);
|
||||||
|
|
|
@ -16,18 +16,26 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.utils;
|
package com.android.inputmethod.latin.utils;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.test.AndroidTestCase;
|
import android.support.test.InstrumentationRegistry;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.support.test.filters.SmallTest;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.common.LocaleUtils;
|
import com.android.inputmethod.latin.common.LocaleUtils;
|
||||||
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class CapsModeUtilsTests extends AndroidTestCase {
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class CapsModeUtilsTests {
|
||||||
private static void onePathForCaps(final CharSequence cs, final int expectedResult,
|
private static void onePathForCaps(final CharSequence cs, final int expectedResult,
|
||||||
final int mask, final SpacingAndPunctuations sp, final boolean hasSpaceBefore) {
|
final int mask, final SpacingAndPunctuations sp, final boolean hasSpaceBefore) {
|
||||||
final int oneTimeResult = expectedResult & mask;
|
final int oneTimeResult = expectedResult & mask;
|
||||||
|
@ -49,6 +57,7 @@ public class CapsModeUtilsTests extends AndroidTestCase {
|
||||||
onePathForCaps(cs, expectedResult, s, sp, hasSpaceBefore);
|
onePathForCaps(cs, expectedResult, s, sp, hasSpaceBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetCapsMode() {
|
public void testGetCapsMode() {
|
||||||
final int c = TextUtils.CAP_MODE_CHARACTERS;
|
final int c = TextUtils.CAP_MODE_CHARACTERS;
|
||||||
final int w = TextUtils.CAP_MODE_WORDS;
|
final int w = TextUtils.CAP_MODE_WORDS;
|
||||||
|
@ -59,7 +68,7 @@ public class CapsModeUtilsTests extends AndroidTestCase {
|
||||||
return new SpacingAndPunctuations(res);
|
return new SpacingAndPunctuations(res);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
final Resources res = getContext().getResources();
|
final Resources res = InstrumentationRegistry.getTargetContext().getResources();
|
||||||
SpacingAndPunctuations sp = job.runInLocale(res, Locale.ENGLISH);
|
SpacingAndPunctuations sp = job.runInLocale(res, Locale.ENGLISH);
|
||||||
allPathsForCaps("", c | w | s, sp, false);
|
allPathsForCaps("", c | w | s, sp, false);
|
||||||
allPathsForCaps("Word", c, sp, false);
|
allPathsForCaps("Word", c, sp, false);
|
||||||
|
|
|
@ -16,11 +16,16 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.utils;
|
package com.android.inputmethod.latin.utils;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import static org.junit.Assert.assertEquals;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.common.CollectionUtils;
|
import com.android.inputmethod.latin.common.CollectionUtils;
|
||||||
|
|
||||||
|
import android.support.test.filters.SmallTest;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -28,15 +33,20 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link CollectionUtils}.
|
* Tests for {@link CollectionUtils}.
|
||||||
*/
|
*/
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class CollectionUtilsTests extends AndroidTestCase {
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class CollectionUtilsTests {
|
||||||
/**
|
/**
|
||||||
* Tests that {@link CollectionUtils#arrayAsList(Object[],int,int)} fails as expected
|
* Tests that {@link CollectionUtils#arrayAsList(Object[],int,int)} fails as expected
|
||||||
* with some invalid inputs.
|
* with some invalid inputs.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testArrayAsListFailure() {
|
public void testArrayAsListFailure() {
|
||||||
final String[] array = { "0", "1" };
|
final String[] array = { "0", "1" };
|
||||||
// Negative start
|
// Negative start
|
||||||
|
@ -66,6 +76,7 @@ public class CollectionUtilsTests extends AndroidTestCase {
|
||||||
* Tests that {@link CollectionUtils#arrayAsList(Object[],int,int)} gives the expected
|
* Tests that {@link CollectionUtils#arrayAsList(Object[],int,int)} gives the expected
|
||||||
* results for a few valid inputs.
|
* results for a few valid inputs.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testArrayAsList() {
|
public void testArrayAsList() {
|
||||||
final ArrayList<String> empty = new ArrayList<>();
|
final ArrayList<String> empty = new ArrayList<>();
|
||||||
assertEquals(empty, CollectionUtils.arrayAsList(new String[] {}, 0, 0));
|
assertEquals(empty, CollectionUtils.arrayAsList(new String[] {}, 0, 0));
|
||||||
|
@ -81,6 +92,7 @@ public class CollectionUtilsTests extends AndroidTestCase {
|
||||||
* Tests that {@link CollectionUtils#isNullOrEmpty(java.util.Collection)} gives the expected
|
* Tests that {@link CollectionUtils#isNullOrEmpty(java.util.Collection)} gives the expected
|
||||||
* results for a few cases.
|
* results for a few cases.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testIsNullOrEmpty() {
|
public void testIsNullOrEmpty() {
|
||||||
assertTrue(CollectionUtils.isNullOrEmpty((List<String>) null));
|
assertTrue(CollectionUtils.isNullOrEmpty((List<String>) null));
|
||||||
assertTrue(CollectionUtils.isNullOrEmpty((Map<String, String>) null));
|
assertTrue(CollectionUtils.isNullOrEmpty((Map<String, String>) null));
|
||||||
|
|
|
@ -16,17 +16,27 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.utils;
|
package com.android.inputmethod.latin.utils;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.test.AndroidTestCase;
|
import android.support.test.InstrumentationRegistry;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.support.test.filters.SmallTest;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.common.LocaleUtils;
|
import com.android.inputmethod.latin.common.LocaleUtils;
|
||||||
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class DictionaryInfoUtilsTests extends AndroidTestCase {
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class DictionaryInfoUtilsTests {
|
||||||
|
@Test
|
||||||
public void testLooksValidForDictionaryInsertion() {
|
public void testLooksValidForDictionaryInsertion() {
|
||||||
final RunInLocale<SpacingAndPunctuations> job = new RunInLocale<SpacingAndPunctuations>() {
|
final RunInLocale<SpacingAndPunctuations> job = new RunInLocale<SpacingAndPunctuations>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,7 +44,7 @@ public class DictionaryInfoUtilsTests extends AndroidTestCase {
|
||||||
return new SpacingAndPunctuations(res);
|
return new SpacingAndPunctuations(res);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
final Resources res = getContext().getResources();
|
final Resources res = InstrumentationRegistry.getTargetContext().getResources();
|
||||||
final SpacingAndPunctuations sp = job.runInLocale(res, Locale.ENGLISH);
|
final SpacingAndPunctuations sp = job.runInLocale(res, Locale.ENGLISH);
|
||||||
assertTrue(DictionaryInfoUtils.looksValidForDictionaryInsertion("aochaueo", sp));
|
assertTrue(DictionaryInfoUtils.looksValidForDictionaryInsertion("aochaueo", sp));
|
||||||
assertFalse(DictionaryInfoUtils.looksValidForDictionaryInsertion("", sp));
|
assertFalse(DictionaryInfoUtils.looksValidForDictionaryInsertion("", sp));
|
||||||
|
@ -46,6 +56,7 @@ public class DictionaryInfoUtilsTests extends AndroidTestCase {
|
||||||
assertFalse(DictionaryInfoUtils.looksValidForDictionaryInsertion("!!!", sp));
|
assertFalse(DictionaryInfoUtils.looksValidForDictionaryInsertion("!!!", sp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetMainDictId() {
|
public void testGetMainDictId() {
|
||||||
assertEquals("main:en",
|
assertEquals("main:en",
|
||||||
DictionaryInfoUtils.getMainDictId(LocaleUtils.constructLocaleFromString("en")));
|
DictionaryInfoUtils.getMainDictId(LocaleUtils.constructLocaleFromString("en")));
|
||||||
|
|
|
@ -16,24 +16,31 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.utils;
|
package com.android.inputmethod.latin.utils;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import static org.junit.Assert.assertEquals;
|
||||||
import android.test.suitebuilder.annotation.MediumTest;
|
|
||||||
|
import android.support.test.filters.MediumTest;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for {@link ExecutorUtils}.
|
* Unit tests for {@link ExecutorUtils}.
|
||||||
*/
|
*/
|
||||||
@MediumTest
|
@MediumTest
|
||||||
public class ExecutorUtilsTests extends AndroidTestCase {
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class ExecutorUtilsTests {
|
||||||
private static final String TAG = ExecutorUtilsTests.class.getSimpleName();
|
private static final String TAG = ExecutorUtilsTests.class.getSimpleName();
|
||||||
|
|
||||||
private static final int NUM_OF_TASKS = 10;
|
private static final int NUM_OF_TASKS = 10;
|
||||||
private static final int DELAY_FOR_WAITING_TASKS_MILLISECONDS = 500;
|
private static final int DELAY_FOR_WAITING_TASKS_MILLISECONDS = 500;
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testExecute() {
|
public void testExecute() {
|
||||||
final ExecutorService executor =
|
final ExecutorService executor =
|
||||||
ExecutorUtils.getBackgroundExecutor(ExecutorUtils.KEYBOARD);
|
ExecutorUtils.getBackgroundExecutor(ExecutorUtils.KEYBOARD);
|
||||||
|
|
|
@ -17,32 +17,39 @@
|
||||||
package com.android.inputmethod.latin.utils;
|
package com.android.inputmethod.latin.utils;
|
||||||
|
|
||||||
import static com.android.inputmethod.latin.utils.ImportantNoticeUtils.KEY_TIMESTAMP_OF_CONTACTS_NOTICE;
|
import static com.android.inputmethod.latin.utils.ImportantNoticeUtils.KEY_TIMESTAMP_OF_CONTACTS_NOTICE;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.test.AndroidTestCase;
|
import android.support.test.InstrumentationRegistry;
|
||||||
import android.test.suitebuilder.annotation.MediumTest;
|
import android.support.test.filters.MediumTest;
|
||||||
import android.text.TextUtils;
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.settings.SettingsValues;
|
import com.android.inputmethod.latin.settings.SettingsValues;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@MediumTest
|
@MediumTest
|
||||||
public class ImportantNoticeUtilsTests extends AndroidTestCase {
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class ImportantNoticeUtilsTests {
|
||||||
|
|
||||||
private ImportantNoticePreferences mImportantNoticePreferences;
|
private ImportantNoticePreferences mImportantNoticePreferences;
|
||||||
|
|
||||||
@Mock private SettingsValues mMockSettingsValues;
|
@Mock private SettingsValues mMockSettingsValues;
|
||||||
|
|
||||||
|
private Context getContext() {
|
||||||
|
return InstrumentationRegistry.getTargetContext();
|
||||||
|
}
|
||||||
|
|
||||||
private static class ImportantNoticePreferences {
|
private static class ImportantNoticePreferences {
|
||||||
private final SharedPreferences mPref;
|
private final SharedPreferences mPref;
|
||||||
|
|
||||||
private Integer mVersion;
|
|
||||||
private Long mLastTime;
|
private Long mLastTime;
|
||||||
|
|
||||||
public ImportantNoticePreferences(final Context context) {
|
public ImportantNoticePreferences(final Context context) {
|
||||||
|
@ -96,21 +103,20 @@ public class ImportantNoticeUtilsTests extends AndroidTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Before
|
||||||
protected void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mImportantNoticePreferences = new ImportantNoticePreferences(getContext());
|
mImportantNoticePreferences = new ImportantNoticePreferences(getContext());
|
||||||
mImportantNoticePreferences.save();
|
mImportantNoticePreferences.save();
|
||||||
when(mMockSettingsValues.isPersonalizationEnabled()).thenReturn(true);
|
when(mMockSettingsValues.isPersonalizationEnabled()).thenReturn(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@After
|
||||||
protected void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
super.tearDown();
|
|
||||||
mImportantNoticePreferences.restore();
|
mImportantNoticePreferences.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testPersonalizationSetting() {
|
public void testPersonalizationSetting() {
|
||||||
mImportantNoticePreferences.clear();
|
mImportantNoticePreferences.clear();
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,23 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.utils;
|
package com.android.inputmethod.latin.utils;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.support.test.filters.SmallTest;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class JsonUtilsTests extends AndroidTestCase {
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class JsonUtilsTests {
|
||||||
|
@Test
|
||||||
public void testJsonUtils() {
|
public void testJsonUtils() {
|
||||||
final Object[] objs = new Object[] { 1, "aaa", "bbb", 3 };
|
final Object[] objs = new Object[] { 1, "aaa", "bbb", 3 };
|
||||||
final List<Object> objArray = Arrays.asList(objs);
|
final List<Object> objArray = Arrays.asList(objs);
|
||||||
|
|
|
@ -19,10 +19,12 @@ package com.android.inputmethod.latin.utils;
|
||||||
import static com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils.FORMAT_TYPE_FULL_LOCALE;
|
import static com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils.FORMAT_TYPE_FULL_LOCALE;
|
||||||
import static com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils.FORMAT_TYPE_LANGUAGE_ONLY;
|
import static com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils.FORMAT_TYPE_LANGUAGE_ONLY;
|
||||||
import static com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils.FORMAT_TYPE_NONE;
|
import static com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils.FORMAT_TYPE_NONE;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.test.AndroidTestCase;
|
import android.support.test.InstrumentationRegistry;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.support.test.filters.SmallTest;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.RichInputMethodManager;
|
import com.android.inputmethod.latin.RichInputMethodManager;
|
||||||
|
@ -36,8 +38,13 @@ import java.util.Locale;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class LanguageOnSpacebarUtilsTests {
|
||||||
private RichInputMethodManager mRichImm;
|
private RichInputMethodManager mRichImm;
|
||||||
|
|
||||||
RichInputMethodSubtype EN_US_QWERTY;
|
RichInputMethodSubtype EN_US_QWERTY;
|
||||||
|
@ -50,10 +57,9 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
|
||||||
RichInputMethodSubtype IW_HEBREW;
|
RichInputMethodSubtype IW_HEBREW;
|
||||||
RichInputMethodSubtype ZZ_QWERTY;
|
RichInputMethodSubtype ZZ_QWERTY;
|
||||||
|
|
||||||
@Override
|
@Before
|
||||||
protected void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
final Context context = InstrumentationRegistry.getTargetContext();
|
||||||
final Context context = getContext();
|
|
||||||
RichInputMethodManager.init(context);
|
RichInputMethodManager.init(context);
|
||||||
mRichImm = RichInputMethodManager.getInstance();
|
mRichImm = RichInputMethodManager.getInstance();
|
||||||
|
|
||||||
|
@ -99,6 +105,7 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
|
||||||
LanguageOnSpacebarUtils.getLanguageOnSpacebarFormatType(subtype));
|
LanguageOnSpacebarUtils.getLanguageOnSpacebarFormatType(subtype));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testOneSubtypeImplicitlyEnabled() {
|
public void testOneSubtypeImplicitlyEnabled() {
|
||||||
enableSubtypes(EN_US_QWERTY);
|
enableSubtypes(EN_US_QWERTY);
|
||||||
assertFormatType(EN_US_QWERTY, true, Locale.US, FORMAT_TYPE_NONE);
|
assertFormatType(EN_US_QWERTY, true, Locale.US, FORMAT_TYPE_NONE);
|
||||||
|
@ -113,6 +120,7 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
|
||||||
assertFormatType(FR_CA_QWERTY, true, Locale.CANADA_FRENCH, FORMAT_TYPE_NONE);
|
assertFormatType(FR_CA_QWERTY, true, Locale.CANADA_FRENCH, FORMAT_TYPE_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testOneSubtypeExplicitlyEnabled() {
|
public void testOneSubtypeExplicitlyEnabled() {
|
||||||
enableSubtypes(EN_US_QWERTY);
|
enableSubtypes(EN_US_QWERTY);
|
||||||
assertFormatType(EN_US_QWERTY, false, Locale.UK, FORMAT_TYPE_LANGUAGE_ONLY);
|
assertFormatType(EN_US_QWERTY, false, Locale.UK, FORMAT_TYPE_LANGUAGE_ONLY);
|
||||||
|
@ -131,6 +139,7 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
|
||||||
assertFormatType(FR_CA_QWERTY, false, Locale.FRANCE, FORMAT_TYPE_LANGUAGE_ONLY);
|
assertFormatType(FR_CA_QWERTY, false, Locale.FRANCE, FORMAT_TYPE_LANGUAGE_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testOneSubtypeImplicitlyEnabledWithNoLanguageSubtype() {
|
public void testOneSubtypeImplicitlyEnabledWithNoLanguageSubtype() {
|
||||||
final Locale Locale_IW = new Locale("iw");
|
final Locale Locale_IW = new Locale("iw");
|
||||||
enableSubtypes(IW_HEBREW, ZZ_QWERTY);
|
enableSubtypes(IW_HEBREW, ZZ_QWERTY);
|
||||||
|
@ -140,6 +149,7 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
|
||||||
assertFormatType(ZZ_QWERTY, true, Locale_IW, FORMAT_TYPE_FULL_LOCALE);
|
assertFormatType(ZZ_QWERTY, true, Locale_IW, FORMAT_TYPE_FULL_LOCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testTwoSubtypesExplicitlyEnabled() {
|
public void testTwoSubtypesExplicitlyEnabled() {
|
||||||
enableSubtypes(EN_US_QWERTY, FR_AZERTY);
|
enableSubtypes(EN_US_QWERTY, FR_AZERTY);
|
||||||
assertFormatType(EN_US_QWERTY, false, Locale.US, FORMAT_TYPE_LANGUAGE_ONLY);
|
assertFormatType(EN_US_QWERTY, false, Locale.US, FORMAT_TYPE_LANGUAGE_ONLY);
|
||||||
|
@ -157,6 +167,7 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testMultiSubtypeWithSameLanuageAndSameLayout() {
|
public void testMultiSubtypeWithSameLanuageAndSameLayout() {
|
||||||
// Explicitly enable en_US, en_GB, fr_FR, and no language keyboards.
|
// Explicitly enable en_US, en_GB, fr_FR, and no language keyboards.
|
||||||
enableSubtypes(EN_US_QWERTY, EN_GB_QWERTY, FR_CA_QWERTY, ZZ_QWERTY);
|
enableSubtypes(EN_US_QWERTY, EN_GB_QWERTY, FR_CA_QWERTY, ZZ_QWERTY);
|
||||||
|
@ -172,6 +183,7 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
|
||||||
assertFormatType(ZZ_QWERTY, false, Locale.JAPAN, FORMAT_TYPE_FULL_LOCALE);
|
assertFormatType(ZZ_QWERTY, false, Locale.JAPAN, FORMAT_TYPE_FULL_LOCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testMultiSubtypesWithSameLanguageButHaveDifferentLayout() {
|
public void testMultiSubtypesWithSameLanguageButHaveDifferentLayout() {
|
||||||
enableSubtypes(FR_AZERTY, FR_CA_QWERTY, FR_CH_SWISS, FR_CH_QWERTZ);
|
enableSubtypes(FR_AZERTY, FR_CA_QWERTY, FR_CH_SWISS, FR_CH_QWERTZ);
|
||||||
|
|
||||||
|
@ -191,6 +203,7 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
|
||||||
assertFormatType(FR_CH_QWERTZ, false, Locale.JAPAN, FORMAT_TYPE_LANGUAGE_ONLY);
|
assertFormatType(FR_CH_QWERTZ, false, Locale.JAPAN, FORMAT_TYPE_LANGUAGE_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testMultiSubtypesWithSameLanguageAndMayHaveSameLayout() {
|
public void testMultiSubtypesWithSameLanguageAndMayHaveSameLayout() {
|
||||||
enableSubtypes(FR_AZERTY, FR_CA_QWERTY, FR_CH_SWISS, FR_CH_QWERTY, FR_CH_QWERTZ);
|
enableSubtypes(FR_AZERTY, FR_CA_QWERTY, FR_CH_SWISS, FR_CH_QWERTY, FR_CH_QWERTZ);
|
||||||
|
|
||||||
|
|
|
@ -16,17 +16,24 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.utils;
|
package com.android.inputmethod.latin.utils;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import static org.junit.Assert.assertEquals;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
|
||||||
|
import android.support.test.filters.SmallTest;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.common.Constants;
|
import com.android.inputmethod.latin.common.Constants;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class RecapitalizeStatusTests extends AndroidTestCase {
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class RecapitalizeStatusTests {
|
||||||
private static final int[] SPACE = { Constants.CODE_SPACE };
|
private static final int[] SPACE = { Constants.CODE_SPACE };
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testTrim() {
|
public void testTrim() {
|
||||||
final RecapitalizeStatus status = new RecapitalizeStatus();
|
final RecapitalizeStatus status = new RecapitalizeStatus();
|
||||||
status.start(30, 40, "abcdefghij", Locale.ENGLISH, SPACE);
|
status.start(30, 40, "abcdefghij", Locale.ENGLISH, SPACE);
|
||||||
|
@ -54,6 +61,7 @@ public class RecapitalizeStatusTests extends AndroidTestCase {
|
||||||
assertEquals(43, status.getNewCursorEnd());
|
assertEquals(43, status.getNewCursorEnd());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testRotate() {
|
public void testRotate() {
|
||||||
final RecapitalizeStatus status = new RecapitalizeStatus();
|
final RecapitalizeStatus status = new RecapitalizeStatus();
|
||||||
status.start(29, 40, "abcd efghij", Locale.ENGLISH, SPACE);
|
status.start(29, 40, "abcd efghij", Locale.ENGLISH, SPACE);
|
||||||
|
|
|
@ -16,13 +16,22 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.utils;
|
package com.android.inputmethod.latin.utils;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import static org.junit.Assert.assertEquals;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
|
import android.support.test.filters.SmallTest;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class ResourceUtilsTests extends AndroidTestCase {
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class ResourceUtilsTests {
|
||||||
|
@Test
|
||||||
public void testFindConstantForKeyValuePairsSimple() {
|
public void testFindConstantForKeyValuePairsSimple() {
|
||||||
final HashMap<String,String> anyKeyValue = new HashMap<>();
|
final HashMap<String,String> anyKeyValue = new HashMap<>();
|
||||||
anyKeyValue.put("anyKey", "anyValue");
|
anyKeyValue.put("anyKey", "anyValue");
|
||||||
|
@ -69,6 +78,7 @@ public class ResourceUtilsTests extends AndroidTestCase {
|
||||||
assertNull(ResourceUtils.findConstantForKeyValuePairs(emptyKeyValue, array));
|
assertNull(ResourceUtils.findConstantForKeyValuePairs(emptyKeyValue, array));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testFindConstantForKeyValuePairsCombined() {
|
public void testFindConstantForKeyValuePairsCombined() {
|
||||||
final String HARDWARE_KEY = "HARDWARE";
|
final String HARDWARE_KEY = "HARDWARE";
|
||||||
final String MODEL_KEY = "MODEL";
|
final String MODEL_KEY = "MODEL";
|
||||||
|
@ -113,6 +123,7 @@ public class ResourceUtilsTests extends AndroidTestCase {
|
||||||
assertEquals("0.2", ResourceUtils.findConstantForKeyValuePairs(keyValues, failArray));
|
assertEquals("0.2", ResourceUtils.findConstantForKeyValuePairs(keyValues, failArray));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testFindConstantForKeyValuePairsRegexp() {
|
public void testFindConstantForKeyValuePairsRegexp() {
|
||||||
final String HARDWARE_KEY = "HARDWARE";
|
final String HARDWARE_KEY = "HARDWARE";
|
||||||
final String MODEL_KEY = "MODEL";
|
final String MODEL_KEY = "MODEL";
|
||||||
|
|
|
@ -16,8 +16,13 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.utils;
|
package com.android.inputmethod.latin.utils;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import static org.junit.Assert.assertEquals;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.test.InstrumentationRegistry;
|
||||||
|
import android.support.test.filters.SmallTest;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
import android.text.style.SuggestionSpan;
|
import android.text.style.SuggestionSpan;
|
||||||
import android.text.style.URLSpan;
|
import android.text.style.URLSpan;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
|
@ -25,8 +30,18 @@ import android.text.SpannableStringBuilder;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.SpannedString;
|
import android.text.SpannedString;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class SpannableStringUtilsTests extends AndroidTestCase {
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class SpannableStringUtilsTests {
|
||||||
|
|
||||||
|
private Context getContext() {
|
||||||
|
return InstrumentationRegistry.getTargetContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testConcatWithSuggestionSpansOnly() {
|
public void testConcatWithSuggestionSpansOnly() {
|
||||||
SpannableStringBuilder s = new SpannableStringBuilder("test string\ntest string\n"
|
SpannableStringBuilder s = new SpannableStringBuilder("test string\ntest string\n"
|
||||||
+ "test string\ntest string\ntest string\ntest string\ntest string\ntest string\n"
|
+ "test string\ntest string\ntest string\ntest string\ntest string\ntest string\n"
|
||||||
|
@ -87,6 +102,7 @@ public class SpannableStringUtilsTests extends AndroidTestCase {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSplitCharSequenceWithSpan() {
|
public void testSplitCharSequenceWithSpan() {
|
||||||
// text: " a bcd efg hij "
|
// text: " a bcd efg hij "
|
||||||
// span1: ^^^^^^^
|
// span1: ^^^^^^^
|
||||||
|
@ -182,6 +198,7 @@ public class SpannableStringUtilsTests extends AndroidTestCase {
|
||||||
assertSpanCount(0, charSequencesFromSpanned[6]);
|
assertSpanCount(0, charSequencesFromSpanned[6]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSplitCharSequencePreserveTrailingEmptySegmengs() {
|
public void testSplitCharSequencePreserveTrailingEmptySegmengs() {
|
||||||
assertEquals(1, SpannableStringUtils.split("", " ",
|
assertEquals(1, SpannableStringUtils.split("", " ",
|
||||||
false /* preserveTrailingEmptySegmengs */).length);
|
false /* preserveTrailingEmptySegmengs */).length);
|
||||||
|
|
|
@ -16,10 +16,16 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.utils;
|
package com.android.inputmethod.latin.utils;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.test.AndroidTestCase;
|
import android.support.test.InstrumentationRegistry;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.support.test.filters.SmallTest;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
import android.view.inputmethod.InputMethodInfo;
|
import android.view.inputmethod.InputMethodInfo;
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
|
|
||||||
|
@ -30,8 +36,14 @@ import com.android.inputmethod.latin.RichInputMethodSubtype;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class SubtypeLocaleUtilsTests extends AndroidTestCase {
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class SubtypeLocaleUtilsTests {
|
||||||
// All input method subtypes of LatinIME.
|
// All input method subtypes of LatinIME.
|
||||||
private final ArrayList<RichInputMethodSubtype> mSubtypesList = new ArrayList<>();
|
private final ArrayList<RichInputMethodSubtype> mSubtypesList = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -64,10 +76,9 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
|
||||||
InputMethodSubtype HI_LATN_DVORAK; // Hinglis Dvorak
|
InputMethodSubtype HI_LATN_DVORAK; // Hinglis Dvorak
|
||||||
InputMethodSubtype SR_LATN_QWERTY; // Serbian Latin Qwerty
|
InputMethodSubtype SR_LATN_QWERTY; // Serbian Latin Qwerty
|
||||||
|
|
||||||
@Override
|
@Before
|
||||||
protected void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
final Context context = InstrumentationRegistry.getTargetContext();
|
||||||
final Context context = getContext();
|
|
||||||
mRes = context.getResources();
|
mRes = context.getResources();
|
||||||
RichInputMethodManager.init(context);
|
RichInputMethodManager.init(context);
|
||||||
mRichImm = RichInputMethodManager.getInstance();
|
mRichImm = RichInputMethodManager.getInstance();
|
||||||
|
@ -136,13 +147,13 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@After
|
||||||
protected void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
// Restore additional subtypes.
|
// Restore additional subtypes.
|
||||||
mRichImm.setAdditionalInputMethodSubtypes(mSavedAddtionalSubtypes);
|
mRichImm.setAdditionalInputMethodSubtypes(mSavedAddtionalSubtypes);
|
||||||
super.tearDown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testAllFullDisplayName() {
|
public void testAllFullDisplayName() {
|
||||||
for (final RichInputMethodSubtype subtype : mSubtypesList) {
|
for (final RichInputMethodSubtype subtype : mSubtypesList) {
|
||||||
final String subtypeName = SubtypeLocaleUtils
|
final String subtypeName = SubtypeLocaleUtils
|
||||||
|
@ -159,6 +170,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testKeyboardLayoutSetName() {
|
public void testKeyboardLayoutSetName() {
|
||||||
assertEquals("en_US", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(EN_US));
|
assertEquals("en_US", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(EN_US));
|
||||||
assertEquals("en_GB", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(EN_GB));
|
assertEquals("en_GB", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(EN_GB));
|
||||||
|
@ -223,6 +235,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
|
||||||
// sr_ZZ qwerty T Serbian (QWERTY) exception
|
// sr_ZZ qwerty T Serbian (QWERTY) exception
|
||||||
// zz pc T Alphabet (PC)
|
// zz pc T Alphabet (PC)
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testPredefinedSubtypesInEnglishSystemLocale() {
|
public void testPredefinedSubtypesInEnglishSystemLocale() {
|
||||||
final RunInLocale<Void> tests = new RunInLocale<Void>() {
|
final RunInLocale<Void> tests = new RunInLocale<Void>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -264,6 +277,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
|
||||||
tests.runInLocale(mRes, Locale.ENGLISH);
|
tests.runInLocale(mRes, Locale.ENGLISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testAdditionalSubtypesInEnglishSystemLocale() {
|
public void testAdditionalSubtypesInEnglishSystemLocale() {
|
||||||
final RunInLocale<Void> tests = new RunInLocale<Void>() {
|
final RunInLocale<Void> tests = new RunInLocale<Void>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -323,6 +337,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
|
||||||
// sr_ZZ qwerty T Serbe (QWERTY) exception
|
// sr_ZZ qwerty T Serbe (QWERTY) exception
|
||||||
// zz pc T Alphabet latin (PC)
|
// zz pc T Alphabet latin (PC)
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testPredefinedSubtypesInFrenchSystemLocale() {
|
public void testPredefinedSubtypesInFrenchSystemLocale() {
|
||||||
final RunInLocale<Void> tests = new RunInLocale<Void>() {
|
final RunInLocale<Void> tests = new RunInLocale<Void>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -364,6 +379,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
|
||||||
tests.runInLocale(mRes, Locale.FRENCH);
|
tests.runInLocale(mRes, Locale.FRENCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testAdditionalSubtypesInFrenchSystemLocale() {
|
public void testAdditionalSubtypesInFrenchSystemLocale() {
|
||||||
final RunInLocale<Void> tests = new RunInLocale<Void>() {
|
final RunInLocale<Void> tests = new RunInLocale<Void>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -405,6 +421,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
|
||||||
// hi_ZZ qwerty F हिंग्लिश
|
// hi_ZZ qwerty F हिंग्लिश
|
||||||
// hi_ZZ dvorak T हिंग्लिश (Dvorak)
|
// hi_ZZ dvorak T हिंग्लिश (Dvorak)
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testHinglishSubtypesInHindiSystemLocale() {
|
public void testHinglishSubtypesInHindiSystemLocale() {
|
||||||
final RunInLocale<Void> tests = new RunInLocale<Void>() {
|
final RunInLocale<Void> tests = new RunInLocale<Void>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -432,6 +449,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
|
||||||
// sr_ZZ serbian_qwertz F Српски (латиница)
|
// sr_ZZ serbian_qwertz F Српски (латиница)
|
||||||
// sr_ZZ qwerty T Српски (QWERTY)
|
// sr_ZZ qwerty T Српски (QWERTY)
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSerbianLatinSubtypesInSerbianSystemLocale() {
|
public void testSerbianLatinSubtypesInSerbianSystemLocale() {
|
||||||
final RunInLocale<Void> tests = new RunInLocale<Void>() {
|
final RunInLocale<Void> tests = new RunInLocale<Void>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -451,6 +469,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
|
||||||
tests.runInLocale(mRes, new Locale("sr"));
|
tests.runInLocale(mRes, new Locale("sr"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testIsRtlLanguage() {
|
public void testIsRtlLanguage() {
|
||||||
// Known Right-to-Left language subtypes.
|
// Known Right-to-Left language subtypes.
|
||||||
final InputMethodSubtype ARABIC = mRichImm
|
final InputMethodSubtype ARABIC = mRichImm
|
||||||
|
|
Loading…
Reference in New Issue