Removing an obsolete test.  Fixing a broken test (ContactLoaderTest)

Change-Id: Ifd655315cff18956b13516edcaa42d5542ec6c26
diff --git a/src/com/android/contacts/list/ContactListFilterController.java b/src/com/android/contacts/list/ContactListFilterController.java
index 21468a0..c9f5530 100644
--- a/src/com/android/contacts/list/ContactListFilterController.java
+++ b/src/com/android/contacts/list/ContactListFilterController.java
@@ -24,7 +24,6 @@
 import android.content.Loader;
 import android.content.SharedPreferences;
 import android.content.res.TypedArray;
-import android.database.Cursor;
 import android.os.Bundle;
 import android.preference.PreferenceManager;
 import android.text.TextUtils;
diff --git a/src/com/android/contacts/model/AccountTypes.java b/src/com/android/contacts/model/AccountTypes.java
index 56080c2..ef5265a 100644
--- a/src/com/android/contacts/model/AccountTypes.java
+++ b/src/com/android/contacts/model/AccountTypes.java
@@ -154,6 +154,7 @@
         for (AccountType accountType : accountTypes) {
             mAccountTypes.put(accountType.accountType, accountType);
         }
+        mInitializationLatch = null;
     }
 
     @Override
diff --git a/tests/Android.mk b/tests/Android.mk
index 4f43e4a..ef11c5e 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -8,8 +8,7 @@
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
 # Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src) \
-    ../src/com/android/contacts/list/ContactsRequest.java
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_PACKAGE_NAME := ContactsTests
 
diff --git a/tests/src/com/android/contacts/ContactLoaderTest.java b/tests/src/com/android/contacts/ContactLoaderTest.java
index 3a4f0da..503fc64 100644
--- a/tests/src/com/android/contacts/ContactLoaderTest.java
+++ b/tests/src/com/android/contacts/ContactLoaderTest.java
@@ -293,6 +293,8 @@
                         Data.PRESENCE, Data.CHAT_CAPABILITY,
                         Data.STATUS, Data.STATUS_RES_PACKAGE, Data.STATUS_ICON,
                         Data.STATUS_LABEL, Data.STATUS_TIMESTAMP,
+
+                        Contacts.PHOTO_URI,
                     })
                     .withSortOrder(Contacts.Entity.RAW_CONTACT_ID)
                     .returnRow(
@@ -324,7 +326,9 @@
 
                         StatusUpdates.INVISIBLE, null,
                         "Having dinner", "mockPkg3", 0,
-                        20, 0
+                        20, 0,
+
+                        "content:some.photo.uri"
                     );
         }
 
diff --git a/tests/src/com/android/contacts/DefaultContactBrowseListFragmentTest.java b/tests/src/com/android/contacts/DefaultContactBrowseListFragmentTest.java
deleted file mode 100644
index 8ad3cb9..0000000
--- a/tests/src/com/android/contacts/DefaultContactBrowseListFragmentTest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2009 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;
-
-import com.android.contacts.list.DefaultContactBrowseListFragment;
-import com.android.contacts.tests.mocks.ContactsMockContext;
-import com.android.contacts.tests.mocks.MockContentProvider;
-import com.android.contacts.widget.TestLoaderManager;
-
-import android.database.Cursor;
-import android.provider.ContactsContract;
-import android.provider.ContactsContract.ContactCounts;
-import android.provider.ContactsContract.Contacts;
-import android.provider.ContactsContract.ProviderStatus;
-import android.provider.ContactsContract.StatusUpdates;
-import android.provider.Settings;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.Smoke;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.ListAdapter;
-import android.widget.ListView;
-
-
-/**
- * Tests for {@link DefaultContactBrowseListFragment}.
- *
- * Running all tests:
- *
- *   runtest contacts
- * or
- *   adb shell am instrument \
- *     -w com.android.contacts.tests/android.test.InstrumentationTestRunner
- */
-@Smoke
-public class DefaultContactBrowseListFragmentTest
-        extends InstrumentationTestCase {
-
-    private ContactsMockContext mContext;
-    private MockContentProvider mContactsProvider;
-    private MockContentProvider mSettingsProvider;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        mContext = new ContactsMockContext(getInstrumentation().getTargetContext());
-        mContactsProvider = mContext.getContactsProvider();
-        mSettingsProvider = mContext.getSettingsProvider();
-    }
-
-    public void testDefaultMode() throws Exception {
-
-        mSettingsProvider.expectQuery(Settings.System.CONTENT_URI)
-                .withProjection(Settings.System.VALUE)
-                .withSelection(Settings.System.NAME + "=?",
-                        ContactsContract.Preferences.DISPLAY_ORDER);
-
-        mSettingsProvider.expectQuery(Settings.System.CONTENT_URI)
-                .withProjection(Settings.System.VALUE)
-                .withSelection(Settings.System.NAME + "=?",
-                        ContactsContract.Preferences.SORT_ORDER);
-
-        mContactsProvider.expectQuery(
-                Contacts.CONTENT_URI.buildUpon()
-                        .appendQueryParameter(ContactCounts.ADDRESS_BOOK_INDEX_EXTRAS, "true")
-                        .build())
-                .withProjection(
-                        Contacts._ID,
-                        Contacts.DISPLAY_NAME,
-                        Contacts.DISPLAY_NAME_ALTERNATIVE,
-                        Contacts.SORT_KEY_PRIMARY,
-                        Contacts.STARRED,
-                        Contacts.CONTACT_PRESENCE,
-                        Contacts.PHOTO_ID,
-                        Contacts.LOOKUP_KEY,
-                        Contacts.PHONETIC_NAME,
-                        Contacts.HAS_PHONE_NUMBER)
-                .withSelection(Contacts.IN_VISIBLE_GROUP + "=1")
-                .withSortOrder(Contacts.SORT_KEY_PRIMARY)
-                .returnRow(1, "John", "John", "john", 1,
-                        StatusUpdates.AVAILABLE, 23, "lk1", "john", 1)
-                .returnRow(2, "Jim", "Jim", "jim", 1,
-                        StatusUpdates.AWAY, 24, "lk2", "jim", 0);
-
-        mContactsProvider.expectQuery(ProviderStatus.CONTENT_URI)
-                .withProjection(ProviderStatus.STATUS, ProviderStatus.DATA1);
-
-        DefaultContactBrowseListFragment fragment = new DefaultContactBrowseListFragment();
-
-        TestLoaderManager loaderManager = new TestLoaderManager();
-
-        // Divert loader registration the TestLoaderManager to ensure that loading is
-        // done synchronously
-        fragment.setLoaderManager(loaderManager);
-
-        // Fragment life cycle
-        fragment.onCreate(null);
-
-        // Instead of attaching the fragment to an activity, "attach" it to the target context
-        // of the instrumentation
-        fragment.setContext(mContext);
-
-        // Fragment life cycle
-        View view = fragment.onCreateView(LayoutInflater.from(mContext), null, null);
-
-        // Fragment life cycle
-        fragment.onStart();
-
-        // All loaders have been registered. Now perform the loading synchronously.
-        loaderManager.executeLoaders();
-
-        // Now we can assert that the data got loaded into the list.
-        ListView listView = (ListView)view.findViewById(android.R.id.list);
-        ListAdapter adapter = listView.getAdapter();
-        assertEquals(3, adapter.getCount());        // It has two items + header view
-
-        // Assert that all queries have been called
-        mSettingsProvider.verify();
-        mContactsProvider.verify();
-    }
-}
diff --git a/tests/src/com/android/contacts/EntityModifierTests.java b/tests/src/com/android/contacts/EntityModifierTests.java
index 84e97c0..349d260 100644
--- a/tests/src/com/android/contacts/EntityModifierTests.java
+++ b/tests/src/com/android/contacts/EntityModifierTests.java
@@ -147,7 +147,7 @@
     /**
      * Build {@link AccountTypes} instance.
      */
-    protected AccountTypes getSources(AccountType... sources) {
+    protected AccountTypes getAccountTypes(AccountType... sources) {
         return new AccountTypes(sources);
     }
 
@@ -498,7 +498,7 @@
 
     public void testTrimInsertEmpty() {
         final AccountType source = getAccountType();
-        final AccountTypes sources = getSources(source);
+        final AccountTypes sources = getAccountTypes(source);
         final DataKind kindPhone = source.getKindForMimetype(Phone.CONTENT_ITEM_TYPE);
         final EditType typeHome = EntityModifier.getType(kindPhone, Phone.TYPE_HOME);
 
@@ -525,7 +525,7 @@
 
     public void testTrimInsertInsert() {
         final AccountType source = getAccountType();
-        final AccountTypes sources = getSources(source);
+        final AccountTypes sources = getAccountTypes(source);
         final DataKind kindPhone = source.getKindForMimetype(Phone.CONTENT_ITEM_TYPE);
         final EditType typeHome = EntityModifier.getType(kindPhone, Phone.TYPE_HOME);
 
@@ -558,7 +558,7 @@
 
     public void testTrimUpdateRemain() {
         final AccountType source = getAccountType();
-        final AccountTypes sources = getSources(source);
+        final AccountTypes sources = getAccountTypes(source);
         final DataKind kindPhone = source.getKindForMimetype(Phone.CONTENT_ITEM_TYPE);
         final EditType typeHome = EntityModifier.getType(kindPhone, Phone.TYPE_HOME);
 
@@ -629,7 +629,7 @@
 
     public void testTrimUpdateUpdate() {
         final AccountType source = getAccountType();
-        final AccountTypes sources = getSources(source);
+        final AccountTypes sources = getAccountTypes(source);
         final DataKind kindPhone = source.getKindForMimetype(Phone.CONTENT_ITEM_TYPE);
         final EditType typeHome = EntityModifier.getType(kindPhone, Phone.TYPE_HOME);
 
diff --git a/tests/src/com/android/contacts/tests/mocks/ContactsMockContext.java b/tests/src/com/android/contacts/tests/mocks/ContactsMockContext.java
index 4697b83..2cce073 100644
--- a/tests/src/com/android/contacts/tests/mocks/ContactsMockContext.java
+++ b/tests/src/com/android/contacts/tests/mocks/ContactsMockContext.java
@@ -16,30 +16,38 @@
 
 package com.android.contacts.tests.mocks;
 
+//import com.android.providers.contacts.ContactsMockPackageManager;
+
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.ContextWrapper;
+import android.content.pm.PackageManager;
+import android.content.pm.ProviderInfo;
 import android.provider.ContactsContract;
 import android.provider.Settings;
 import android.test.mock.MockContentResolver;
 
 /**
- * A mock context for contact activity unit tests. Forwards everything to
+ * A mock context for contacts unit tests. Forwards everything to
  * a supplied context, except content resolver operations, which are sent
  * to mock content providers.
  */
 public class ContactsMockContext extends ContextWrapper {
 
+    private ContactsMockPackageManager mPackageManager;
     private MockContentResolver mContentResolver;
     private MockContentProvider mContactsProvider;
     private MockContentProvider mSettingsProvider;
 
     public ContactsMockContext(Context base) {
         super(base);
+        mPackageManager = new ContactsMockPackageManager();
         mContentResolver = new MockContentResolver();
         mContactsProvider = new MockContentProvider();
         mContentResolver.addProvider(ContactsContract.AUTHORITY, mContactsProvider);
+        mContactsProvider.attachInfo(this, new ProviderInfo());
         mSettingsProvider = new MockContentProvider();
+        mSettingsProvider.attachInfo(this, new ProviderInfo());
         mContentResolver.addProvider(Settings.AUTHORITY, mSettingsProvider);
     }
 
@@ -57,7 +65,17 @@
     }
 
     @Override
+    public PackageManager getPackageManager() {
+        return mPackageManager;
+    }
+
+    @Override
     public Context getApplicationContext() {
         return this;
     }
+
+    public void verify() {
+        mContactsProvider.verify();
+        mSettingsProvider.verify();
+    }
 }
diff --git a/tests/src/com/android/contacts/tests/mocks/ContactsMockPackageManager.java b/tests/src/com/android/contacts/tests/mocks/ContactsMockPackageManager.java
new file mode 100644
index 0000000..3095d69
--- /dev/null
+++ b/tests/src/com/android/contacts/tests/mocks/ContactsMockPackageManager.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2010 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.tests.mocks;
+
+import android.content.ComponentName;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
+import android.test.mock.MockPackageManager;
+
+/**
+ */
+public class ContactsMockPackageManager extends MockPackageManager {
+    public ContactsMockPackageManager() {
+    }
+
+    @Override
+    public Drawable getActivityLogo(ComponentName activityName) throws NameNotFoundException {
+        return new ColorDrawable();
+    }
+
+    @Override
+    public Drawable getActivityIcon(ComponentName activityName) {
+        return new ColorDrawable();
+    }
+
+    @Override
+    public Drawable getDrawable(String packageName, int resid, ApplicationInfo appInfo) {
+        // TODO: make programmable
+        return new ColorDrawable();
+    }
+}