summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBrandon Maxwell <maxwelb@google.com>2015-10-23 21:06:54 +0000
committerBrandon Maxwell <maxwelb@google.com>2015-10-23 21:06:54 +0000
commit5a1585626866ec41e0ab21f05d52e504fe4b960d (patch)
tree82c663cbc92a3aff190a44256be65efb76364a1d /tests
parentcfaee482a616fb8a50fc16cad62cefab5efd72bd (diff)
downloadandroid_packages_apps_ContactsCommon-5a1585626866ec41e0ab21f05d52e504fe4b960d.tar.gz
android_packages_apps_ContactsCommon-5a1585626866ec41e0ab21f05d52e504fe4b960d.tar.bz2
android_packages_apps_ContactsCommon-5a1585626866ec41e0ab21f05d52e504fe4b960d.zip
Revert "Fixing refresh bug with ContactsPreferences"
This reverts commit cfaee482a616fb8a50fc16cad62cefab5efd72bd. Change-Id: I93f6fc9a9dbd5546495a1187011234a569582077
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/contacts/common/model/account/AccountTypeTest.java2
-rw-r--r--tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java2
-rw-r--r--tests/src/com/android/contacts/common/preference/ContactsPreferencesTest.java147
3 files changed, 2 insertions, 149 deletions
diff --git a/tests/src/com/android/contacts/common/model/account/AccountTypeTest.java b/tests/src/com/android/contacts/common/model/account/AccountTypeTest.java
index 6a406115..8dc7df75 100644
--- a/tests/src/com/android/contacts/common/model/account/AccountTypeTest.java
+++ b/tests/src/com/android/contacts/common/model/account/AccountTypeTest.java
@@ -20,7 +20,7 @@ import android.content.Context;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
-import com.android.contacts.common.R;
+import com.android.contacts.common.unittest.R;
/**
* Test case for {@link AccountType}.
diff --git a/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java b/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java
index dc3da45e..932dddc0 100644
--- a/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java
+++ b/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java
@@ -33,7 +33,7 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;
import com.android.contacts.common.model.dataitem.DataKind;
-import com.android.contacts.common.R;
+import com.android.contacts.common.unittest.R;
import com.google.common.base.Objects;
import java.util.List;
diff --git a/tests/src/com/android/contacts/common/preference/ContactsPreferencesTest.java b/tests/src/com/android/contacts/common/preference/ContactsPreferencesTest.java
deleted file mode 100644
index 6ed5937f..00000000
--- a/tests/src/com/android/contacts/common/preference/ContactsPreferencesTest.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2015 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.contacts.common.preference;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.res.Resources;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-
-import com.android.contacts.common.model.account.AccountWithDataSet;
-
-import junit.framework.Assert;
-
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-
-@MediumTest
-public class ContactsPreferencesTest extends AndroidTestCase {
-
- private static final String ACCOUNT_KEY = "ACCOUNT_KEY";
-
- @Mock private Context mContext;
- @Mock private Resources mResources;
- @Mock private SharedPreferences mSharedPreferences;
-
- private ContactsPreferences mContactsPreferences;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- MockitoAnnotations.initMocks(this);
-
- Mockito.when(mContext.getResources()).thenReturn(mResources);
- Mockito.when(mResources.getString(Mockito.anyInt()))
- .thenReturn(ACCOUNT_KEY); // contact_editor_default_account_key
-
- Mockito.when(mContext.getSharedPreferences(Mockito.anyString(), Mockito.anyInt()))
- .thenReturn(mSharedPreferences);
- Mockito.when(mSharedPreferences.contains(ContactsPreferences.SORT_ORDER_KEY))
- .thenReturn(true);
- Mockito.when(mSharedPreferences.contains(ContactsPreferences.DISPLAY_ORDER_KEY))
- .thenReturn(true);
-
- mContactsPreferences = new ContactsPreferences(mContext);
- }
-
- public void testGetSortOrderDefault() {
- Mockito.when(mResources.getBoolean(Mockito.anyInt())).thenReturn(
- false, // R.bool.config_sort_order_user_changeable
- true // R.bool.config_default_sort_order_primary
- );
- Assert.assertEquals(ContactsPreferences.SORT_ORDER_PRIMARY,
- mContactsPreferences.getSortOrder());
- }
-
- public void testGetSortOrder() {
- Mockito.when(mResources.getBoolean(Mockito.anyInt())).thenReturn(
- true // R.bool.config_sort_order_user_changeable
- );
- Mockito.when(mSharedPreferences.getInt(Mockito.eq(ContactsPreferences.SORT_ORDER_KEY),
- Mockito.anyInt())).thenReturn(ContactsPreferences.SORT_ORDER_PRIMARY);
- Assert.assertEquals(ContactsPreferences.SORT_ORDER_PRIMARY,
- mContactsPreferences.getSortOrder());
- }
-
- public void testGetDisplayOrderDefault() {
- Mockito.when(mResources.getBoolean(Mockito.anyInt())).thenReturn(
- false, // R.bool.config_display_order_user_changeable
- true // R.bool.config_default_display_order_primary
- );
- Assert.assertEquals(ContactsPreferences.DISPLAY_ORDER_PRIMARY,
- mContactsPreferences.getDisplayOrder());
- }
-
- public void testGetDisplayOrder() {
- Mockito.when(mResources.getBoolean(Mockito.anyInt())).thenReturn(
- true // R.bool.config_display_order_user_changeable
- );
- Mockito.when(mSharedPreferences.getInt(Mockito.eq(ContactsPreferences.DISPLAY_ORDER_KEY),
- Mockito.anyInt())).thenReturn(ContactsPreferences.DISPLAY_ORDER_PRIMARY);
- Assert.assertEquals(ContactsPreferences.DISPLAY_ORDER_PRIMARY,
- mContactsPreferences.getDisplayOrder());
- }
-
- public void testRefreshSortOrder() throws InterruptedException {
- Mockito.when(mResources.getBoolean(Mockito.anyInt())).thenReturn(
- true // R.bool.config_sort_order_user_changeable
- );
- Mockito.when(mSharedPreferences.getInt(Mockito.eq(ContactsPreferences.SORT_ORDER_KEY),
- Mockito.anyInt())).thenReturn(ContactsPreferences.SORT_ORDER_PRIMARY,
- ContactsPreferences.SORT_ORDER_ALTERNATIVE);
-
- Assert.assertEquals(ContactsPreferences.SORT_ORDER_PRIMARY,
- mContactsPreferences.getSortOrder());
- mContactsPreferences.refreshValue(ContactsPreferences.SORT_ORDER_KEY);
-
- Assert.assertEquals(ContactsPreferences.SORT_ORDER_ALTERNATIVE,
- mContactsPreferences.getSortOrder());
- }
-
- public void testRefreshDisplayOrder() throws InterruptedException {
- Mockito.when(mResources.getBoolean(Mockito.anyInt())).thenReturn(
- true // R.bool.config_display_order_user_changeable
- );
- Mockito.when(mSharedPreferences.getInt(Mockito.eq(ContactsPreferences.DISPLAY_ORDER_KEY),
- Mockito.anyInt())).thenReturn(ContactsPreferences.DISPLAY_ORDER_PRIMARY,
- ContactsPreferences.DISPLAY_ORDER_ALTERNATIVE);
-
- Assert.assertEquals(ContactsPreferences.DISPLAY_ORDER_PRIMARY,
- mContactsPreferences.getDisplayOrder());
- mContactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY);
-
- Assert.assertEquals(ContactsPreferences.DISPLAY_ORDER_ALTERNATIVE,
- mContactsPreferences.getDisplayOrder());
- }
-
- public void testRefreshDefaultAccount() throws InterruptedException {
- Mockito.when(mResources.getBoolean(Mockito.anyInt())).thenReturn(
- true // R.bool.config_default_account_user_changeable
- );
-
- Mockito.when(mSharedPreferences.getString(Mockito.eq(ACCOUNT_KEY), Mockito.anyString()))
- .thenReturn(new AccountWithDataSet("name1", "type1", "dataset1").stringify(),
- new AccountWithDataSet("name2", "type2", "dataset2").stringify());
-
- Assert.assertEquals("name1", mContactsPreferences.getDefaultAccount());
- mContactsPreferences.refreshValue(ACCOUNT_KEY);
-
- Assert.assertEquals("name2", mContactsPreferences.getDefaultAccount());
- }
-}