diff options
author | Jay Shrauner <shrauner@google.com> | 2013-03-07 12:35:01 -0800 |
---|---|---|
committer | Jay Shrauner <shrauner@google.com> | 2013-03-07 12:35:01 -0800 |
commit | 6fabfd02577c9c631cd371131c3e161122329777 (patch) | |
tree | fb9f471ba81ccbc91e033840378488572bd26438 /src/com/android/providers/contacts/FastScrollingIndexCache.java | |
parent | 9f675502e2ab04e37b043d29d82b1d19458cd1b2 (diff) | |
download | packages_providers_ContactsProvider-6fabfd02577c9c631cd371131c3e161122329777.zip packages_providers_ContactsProvider-6fabfd02577c9c631cd371131c3e161122329777.tar.gz packages_providers_ContactsProvider-6fabfd02577c9c631cd371131c3e161122329777.tar.bz2 |
Fix FastScrollingIndexCache test
Make sure the FastScrollingIndexCache instance used for the unit tests
was created with the correct MockSharedPreferences
Bug:
Change-Id: I612638dadab394ea3ed8abbbe6f47de5f17601fe
Diffstat (limited to 'src/com/android/providers/contacts/FastScrollingIndexCache.java')
-rw-r--r-- | src/com/android/providers/contacts/FastScrollingIndexCache.java | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/com/android/providers/contacts/FastScrollingIndexCache.java b/src/com/android/providers/contacts/FastScrollingIndexCache.java index 9b3908e..e535225 100644 --- a/src/com/android/providers/contacts/FastScrollingIndexCache.java +++ b/src/com/android/providers/contacts/FastScrollingIndexCache.java @@ -88,24 +88,22 @@ public class FastScrollingIndexCache { private static FastScrollingIndexCache sSingleton; public static FastScrollingIndexCache getInstance(Context context) { - return getInstance(PreferenceManager.getDefaultSharedPreferences(context)); - } - - public static synchronized FastScrollingIndexCache getInstance( - SharedPreferences prefs) { if (sSingleton == null) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); sSingleton = new FastScrollingIndexCache(prefs); } return sSingleton; } - private FastScrollingIndexCache(SharedPreferences prefs) { - mPrefs = prefs; + @VisibleForTesting + static synchronized FastScrollingIndexCache getInstanceForTest( + SharedPreferences prefs) { + sSingleton = new FastScrollingIndexCache(prefs); + return sSingleton; } - @VisibleForTesting - protected static synchronized void releaseInstance() { - sSingleton = null; + private FastScrollingIndexCache(SharedPreferences prefs) { + mPrefs = prefs; } /** |