summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authoravipul <avipul@google.com>2017-02-28 12:14:44 -0800
committeravipul <avipul@google.com>2017-02-28 14:56:08 -0800
commit030b126e6048050154392c72ad451fa73aa37a7f (patch)
tree5d15c11344a7242d302892a6eebb6f30e97e7a70 /tests
parent365a5f756f314b22e48323af336bb90041a10ca9 (diff)
downloadContacts-030b126e6048050154392c72ad451fa73aa37a7f.tar.gz
Fixes unit tests for ContactsPreferences
Also, makes PhoneticNameDisplay preference configurable. Test: Auotomated test is added to verify PhoneticNameDisplay preference in ContactPreference. Manually tested by changing the config_phonetic_name_display_user_changeable. False to removed the option from settings. True to display the option in Settings. Bug: 35811420 Change-Id: I395ed4a3539c90d8aa1731d1590930481ae31097
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/contacts/preference/ContactsPreferencesTest.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/src/com/android/contacts/preference/ContactsPreferencesTest.java b/tests/src/com/android/contacts/preference/ContactsPreferencesTest.java
index 7da9099ce..bea8d147a 100644
--- a/tests/src/com/android/contacts/preference/ContactsPreferencesTest.java
+++ b/tests/src/com/android/contacts/preference/ContactsPreferencesTest.java
@@ -61,6 +61,8 @@ public class ContactsPreferencesTest extends InstrumentationTestCase {
.thenReturn(true);
Mockito.when(mSharedPreferences.contains(ContactsPreferences.DISPLAY_ORDER_KEY))
.thenReturn(true);
+ Mockito.when(mSharedPreferences.contains(ContactsPreferences.PHONETIC_NAME_DISPLAY_KEY))
+ .thenReturn(true);
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
@@ -108,6 +110,43 @@ public class ContactsPreferencesTest extends InstrumentationTestCase {
mContactsPreferences.getDisplayOrder());
}
+ public void testGetPhoneticNameDisplayDefault() {
+ Mockito.when(mResources.getBoolean(Mockito.anyInt())).thenReturn(
+ false, // R.bool.config_phonetic_name_display_user_changeable
+ true // R.bool.config_default_hide_phonetic_name_if_empty
+ );
+ Assert.assertEquals(PhoneticNameDisplayPreference.HIDE_IF_EMPTY,
+ mContactsPreferences.getPhoneticNameDisplayPreference());
+ }
+
+ public void testGetPhoneticNameDisplay() {
+ Mockito.when(mResources.getBoolean(Mockito.anyInt())).thenReturn(
+ true // R.bool.config_phonetic_name_display_user_changeable
+ );
+ Mockito.when(mSharedPreferences.getInt(
+ Mockito.eq(ContactsPreferences.PHONETIC_NAME_DISPLAY_KEY),
+ Mockito.anyInt())).thenReturn(PhoneticNameDisplayPreference.HIDE_IF_EMPTY);
+ Assert.assertEquals(PhoneticNameDisplayPreference.HIDE_IF_EMPTY,
+ mContactsPreferences.getPhoneticNameDisplayPreference());
+ }
+
+ public void testRefreshPhoneticNameDisplay() throws InterruptedException {
+ Mockito.when(mResources.getBoolean(Mockito.anyInt())).thenReturn(
+ true // R.bool.config_phonetic_name_display_user_changeable
+ );
+ Mockito.when(mSharedPreferences.getInt(
+ Mockito.eq(ContactsPreferences.PHONETIC_NAME_DISPLAY_KEY),
+ Mockito.anyInt())).thenReturn(PhoneticNameDisplayPreference.HIDE_IF_EMPTY,
+ PhoneticNameDisplayPreference.SHOW_ALWAYS);
+
+ Assert.assertEquals(PhoneticNameDisplayPreference.HIDE_IF_EMPTY,
+ mContactsPreferences.getPhoneticNameDisplayPreference());
+ mContactsPreferences.refreshValue(ContactsPreferences.PHONETIC_NAME_DISPLAY_KEY);
+
+ Assert.assertEquals(PhoneticNameDisplayPreference.SHOW_ALWAYS,
+ mContactsPreferences.getPhoneticNameDisplayPreference());
+ }
+
public void testRefreshSortOrder() throws InterruptedException {
Mockito.when(mResources.getBoolean(Mockito.anyInt())).thenReturn(
true // R.bool.config_sort_order_user_changeable