aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin/accounts/AccountsChangedReceiverTests.java
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2018-07-06 10:10:54 -0700
committerYohei Yukawa <yukawa@google.com>2018-07-06 10:10:54 -0700
commitd3b93cc95061ada6a162d7989e313f818e6d4e15 (patch)
treea4e3eaee6b84d20817d82b2a263e0e47bcc98753 /tests/src/com/android/inputmethod/latin/accounts/AccountsChangedReceiverTests.java
parenta497886dda70bbd401652560d11d8f4010985e96 (diff)
downloadlatinime-d3b93cc95061ada6a162d7989e313f818e6d4e15.tar.gz
latinime-d3b93cc95061ada6a162d7989e313f818e6d4e15.tar.xz
latinime-d3b93cc95061ada6a162d7989e313f818e6d4e15.zip
Migrate to Android Testing Support Lib (part 5/N)
This CL converts 19 test classes under com.android.inputmethod.latin 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 Change-Id: I878fcae0126f57c43a644af341e5a0a8ac8f5cc9
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/accounts/AccountsChangedReceiverTests.java')
-rw-r--r--tests/src/com/android/inputmethod/latin/accounts/AccountsChangedReceiverTests.java33
1 files changed, 25 insertions, 8 deletions
diff --git a/tests/src/com/android/inputmethod/latin/accounts/AccountsChangedReceiverTests.java b/tests/src/com/android/inputmethod/latin/accounts/AccountsChangedReceiverTests.java
index 832817967..aa2a5c2cf 100644
--- a/tests/src/com/android/inputmethod/latin/accounts/AccountsChangedReceiverTests.java
+++ b/tests/src/com/android/inputmethod/latin/accounts/AccountsChangedReceiverTests.java
@@ -16,40 +16,54 @@
package com.android.inputmethod.latin.accounts;
+import static org.junit.Assert.assertEquals;
+
import android.accounts.AccountManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
-import android.test.AndroidTestCase;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
import com.android.inputmethod.latin.settings.LocalSettingsConstants;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
/**
* Tests for {@link AccountsChangedReceiver}.
*/
-public class AccountsChangedReceiverTests extends AndroidTestCase {
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class AccountsChangedReceiverTests {
private static final String ACCOUNT_1 = "account1@example.com";
private static final String ACCOUNT_2 = "account2@example.com";
private SharedPreferences mPrefs;
private String mLastKnownAccount = null;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ private Context getContext() {
+ return InstrumentationRegistry.getTargetContext();
+ }
+
+ @Before
+ public void setUp() throws Exception {
mPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
// Keep track of the current account so that we restore it when the test finishes.
mLastKnownAccount = mPrefs.getString(LocalSettingsConstants.PREF_ACCOUNT_NAME, null);
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
// Restore the account that was present before running the test.
updateAccountName(mLastKnownAccount);
}
+ @Test
public void testUnknownIntent() {
updateAccountName(ACCOUNT_1);
AccountsChangedReceiver reciever = new AccountsChangedReceiver();
@@ -58,6 +72,7 @@ public class AccountsChangedReceiverTests extends AndroidTestCase {
assertAccountName(ACCOUNT_1);
}
+ @Test
public void testAccountRemoved() {
updateAccountName(ACCOUNT_1);
AccountsChangedReceiver reciever = new AccountsChangedReceiver() {
@@ -71,6 +86,7 @@ public class AccountsChangedReceiverTests extends AndroidTestCase {
assertAccountName(null);
}
+ @Test
public void testAccountRemoved_noAccounts() {
updateAccountName(ACCOUNT_2);
AccountsChangedReceiver reciever = new AccountsChangedReceiver() {
@@ -84,6 +100,7 @@ public class AccountsChangedReceiverTests extends AndroidTestCase {
assertAccountName(null);
}
+ @Test
public void testAccountNotRemoved() {
updateAccountName(ACCOUNT_2);
AccountsChangedReceiver reciever = new AccountsChangedReceiver() {