diff options
author | 2018-07-05 13:45:04 -0700 | |
---|---|---|
committer | 2018-07-05 13:45:04 -0700 | |
commit | 9c49581eeb96ebf6ca4dc2110ea986d784c48912 (patch) | |
tree | 403e5d84a56be67fa3a8bb17864322e8a2d393b5 /tests/src/com/android/inputmethod/latin/utils/ImportantNoticeUtilsTests.java | |
parent | 2802250415af3bfe57bab6826966a35f75a4ec86 (diff) | |
download | latinime-9c49581eeb96ebf6ca4dc2110ea986d784c48912.tar.gz latinime-9c49581eeb96ebf6ca4dc2110ea986d784c48912.tar.xz latinime-9c49581eeb96ebf6ca4dc2110ea986d784c48912.zip |
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: I5cc2ddbc4116003ab6407432ab521b6b560052ae
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/utils/ImportantNoticeUtilsTests.java')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/utils/ImportantNoticeUtilsTests.java | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/tests/src/com/android/inputmethod/latin/utils/ImportantNoticeUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/ImportantNoticeUtilsTests.java index df0180729..8c004bf8a 100644 --- a/tests/src/com/android/inputmethod/latin/utils/ImportantNoticeUtilsTests.java +++ b/tests/src/com/android/inputmethod/latin/utils/ImportantNoticeUtilsTests.java @@ -17,32 +17,39 @@ package com.android.inputmethod.latin.utils; 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 android.content.Context; import android.content.SharedPreferences; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.MediumTest; -import android.text.TextUtils; +import android.support.test.InstrumentationRegistry; +import android.support.test.filters.MediumTest; +import android.support.test.runner.AndroidJUnit4; 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.MockitoAnnotations; -import java.util.concurrent.TimeUnit; - @MediumTest -public class ImportantNoticeUtilsTests extends AndroidTestCase { +@RunWith(AndroidJUnit4.class) +public class ImportantNoticeUtilsTests { private ImportantNoticePreferences mImportantNoticePreferences; @Mock private SettingsValues mMockSettingsValues; + private Context getContext() { + return InstrumentationRegistry.getTargetContext(); + } + private static class ImportantNoticePreferences { private final SharedPreferences mPref; - private Integer mVersion; private Long mLastTime; public ImportantNoticePreferences(final Context context) { @@ -96,21 +103,20 @@ public class ImportantNoticeUtilsTests extends AndroidTestCase { } } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mImportantNoticePreferences = new ImportantNoticePreferences(getContext()); mImportantNoticePreferences.save(); when(mMockSettingsValues.isPersonalizationEnabled()).thenReturn(true); } - @Override - protected void tearDown() throws Exception { - super.tearDown(); + @After + public void tearDown() throws Exception { mImportantNoticePreferences.restore(); } + @Test public void testPersonalizationSetting() { mImportantNoticePreferences.clear(); |