Fix tests

- Fix testMigratePhoneFromGoogleToExchange

We forgot to update this test when we changed the default phone type
to MOBILE.

Bug 5928504

- Fix NoSuchMethodError

Now that Preconditions.* aren't used in the main source, these are stripped
down by proguard.  Don't use them in the test.

Change-Id: Idfeed7e92e4f95c150bcbc797e71b4e5fe9ef68b
diff --git a/tests/src/com/android/contacts/CallDetailActivityTest.java b/tests/src/com/android/contacts/CallDetailActivityTest.java
index ac02588..689f946 100644
--- a/tests/src/com/android/contacts/CallDetailActivityTest.java
+++ b/tests/src/com/android/contacts/CallDetailActivityTest.java
@@ -25,7 +25,6 @@
 import com.android.contacts.util.IntegrationTestUtils;
 import com.android.contacts.util.LocaleTestUtils;
 import com.android.internal.view.menu.ContextMenuBuilder;
-import com.google.common.base.Preconditions;
 import com.google.common.io.Closeables;
 
 import android.content.ContentResolver;
@@ -227,7 +226,7 @@
     }
 
     private void setActivityIntentForTestCallEntry() {
-        Preconditions.checkState(mCallLogUri == null, "mUri should be null");
+        assertNull(mCallLogUri);
         ContentResolver contentResolver = getContentResolver();
         ContentValues values = new ContentValues();
         values.put(CallLog.Calls.NUMBER, CONTACT_NUMBER);
@@ -237,7 +236,7 @@
     }
 
     private void setActivityIntentForTestVoicemailEntry() {
-        Preconditions.checkState(mVoicemailUri == null, "mUri should be null");
+        assertNull(mVoicemailUri);
         ContentResolver contentResolver = getContentResolver();
         ContentValues values = new ContentValues();
         values.put(VoicemailContract.Voicemails.NUMBER, CONTACT_NUMBER);
@@ -252,7 +251,7 @@
     }
 
     private void setActivityIntentForRealFileVoicemailEntry() throws IOException {
-        Preconditions.checkState(mVoicemailUri == null, "mUri should be null");
+        assertNull(mVoicemailUri);
         ContentValues values = new ContentValues();
         values.put(VoicemailContract.Voicemails.DATE, String.valueOf(System.currentTimeMillis()));
         values.put(VoicemailContract.Voicemails.NUMBER, CONTACT_NUMBER);
@@ -307,7 +306,7 @@
     }
 
     private TextView assertHasOneTextViewContaining(String text) throws Throwable {
-        Preconditions.checkNotNull(mActivityUnderTest, "forget to call startActivityUnderTest()?");
+        assertNotNull(mActivityUnderTest);
         List<TextView> views = mTestUtils.getTextViewsWithString(mActivityUnderTest, text);
         assertEquals("There should have been one TextView with text '" + text + "' but found "
                 + views, 1, views.size());
@@ -315,14 +314,14 @@
     }
 
     private void assertZeroTextViewsContaining(String text) throws Throwable {
-        Preconditions.checkNotNull(mActivityUnderTest, "forget to call startActivityUnderTest()?");
+        assertNotNull(mActivityUnderTest);
         List<TextView> views = mTestUtils.getTextViewsWithString(mActivityUnderTest, text);
         assertEquals("There should have been no TextViews with text '" + text + "' but found "
                 + views, 0,  views.size());
     }
 
     private void startActivityUnderTest() throws Throwable {
-        Preconditions.checkState(mActivityUnderTest == null, "must only start the activity once");
+        assertNull(mActivityUnderTest);
         mActivityUnderTest = getActivity();
         assertNotNull("activity should not be null", mActivityUnderTest);
         // We have to run all tasks, not just one.
diff --git a/tests/src/com/android/contacts/EntityModifierTests.java b/tests/src/com/android/contacts/EntityModifierTests.java
index 6872604..df4934a 100644
--- a/tests/src/com/android/contacts/EntityModifierTests.java
+++ b/tests/src/com/android/contacts/EntityModifierTests.java
@@ -1130,6 +1130,25 @@
         AccountType newAccountType = new ExchangeAccountType(getContext(), "");
         DataKind kind = newAccountType.getKindForMimetype(Phone.CONTENT_ITEM_TYPE);
 
+        // Create 5 numbers.
+        // - "1" -- HOME
+        // - "2" -- WORK
+        // - "3" -- CUSTOM
+        // - "4" -- WORK
+        // - "5" -- WORK_MOBILE
+        // Then we convert it to Exchange account type.
+        // - "1" -- HOME
+        // - "2" -- WORK
+        // - "3" -- Because CUSTOM is not supported, it'll be changed to the default, MOBILE
+        // - "4" -- WORK
+        // - "5" -- WORK_MOBILE not suppoted again, so will be MOBILE.
+        // But then, Exchange doesn't support multiple MOBILE numbers, so "5" will be removed.
+        // i.e. the result will be:
+        // - "1" -- HOME
+        // - "2" -- WORK
+        // - "3" -- MOBILE
+        // - "4" -- WORK
+
         EntityDelta oldState = new EntityDelta();
         ContentValues mockNameValues = new ContentValues();
         mockNameValues.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
@@ -1138,12 +1157,12 @@
         oldState.addEntry(ValuesDelta.fromAfter(mockNameValues));
         mockNameValues = new ContentValues();
         mockNameValues.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
-        mockNameValues.put(Phone.TYPE, Phone.TYPE_MOBILE);
+        mockNameValues.put(Phone.TYPE, Phone.TYPE_WORK);
         mockNameValues.put(Phone.NUMBER, "2");
         oldState.addEntry(ValuesDelta.fromAfter(mockNameValues));
         mockNameValues = new ContentValues();
         mockNameValues.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
-        // Exchange doesn't support this type. Default to HOME
+        // Exchange doesn't support this type. Default to MOBILE
         mockNameValues.put(Phone.TYPE, Phone.TYPE_CUSTOM);
         mockNameValues.put(Phone.LABEL, "custom_type");
         mockNameValues.put(Phone.NUMBER, "3");
@@ -1155,8 +1174,6 @@
         oldState.addEntry(ValuesDelta.fromAfter(mockNameValues));
         mockNameValues = new ContentValues();
 
-        // This field should be ignored, as Exchange only allows 2 HOME phone numbers while we
-        // already have that number of HOME phones.
         mockNameValues.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
         mockNameValues.put(Phone.TYPE, Phone.TYPE_WORK_MOBILE);
         mockNameValues.put(Phone.NUMBER, "5");
@@ -1169,13 +1186,13 @@
         assertNotNull(list);
         assertEquals(4, list.size());
 
-        int defaultType = kind.typeList.get(0).rawValue;
+        int defaultType = Phone.TYPE_MOBILE;
 
         ContentValues outputValues = list.get(0).getAfter();
         assertEquals(Phone.TYPE_HOME, outputValues.getAsInteger(Phone.TYPE).intValue());
         assertEquals("1", outputValues.getAsString(Phone.NUMBER));
         outputValues = list.get(1).getAfter();
-        assertEquals(Phone.TYPE_MOBILE, outputValues.getAsInteger(Phone.TYPE).intValue());
+        assertEquals(Phone.TYPE_WORK, outputValues.getAsInteger(Phone.TYPE).intValue());
         assertEquals("2", outputValues.getAsString(Phone.NUMBER));
         outputValues = list.get(2).getAfter();
         assertEquals(defaultType, outputValues.getAsInteger(Phone.TYPE).intValue());
diff --git a/tests/src/com/android/contacts/util/FakeAsyncTaskExecutor.java b/tests/src/com/android/contacts/util/FakeAsyncTaskExecutor.java
index 960f0bf..e68c0ec 100644
--- a/tests/src/com/android/contacts/util/FakeAsyncTaskExecutor.java
+++ b/tests/src/com/android/contacts/util/FakeAsyncTaskExecutor.java
@@ -16,10 +16,6 @@
 
 package com.android.contacts.util;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 
 import android.app.Instrumentation;
@@ -65,7 +61,8 @@
 
     /** Create a fake AsyncTaskExecutor for use in unit tests. */
     public FakeAsyncTaskExecutor(Instrumentation instrumentation) {
-        mInstrumentation = checkNotNull(instrumentation);
+        Assert.assertNotNull(instrumentation);
+        mInstrumentation = instrumentation;
     }
 
     /** Encapsulates an async task with the params and identifier it was submitted with. */
@@ -116,8 +113,9 @@
         @Override
         public void execute(Runnable command) {
             synchronized (mNextLock) {
+                Assert.assertNotNull(mNextTask);
                 mSubmittedTasks.add(new SubmittedTaskImpl(mNextIdentifier,
-                        command, checkNotNull(mNextTask)));
+                        command, mNextTask));
                 mNextIdentifier = null;
                 mNextTask = null;
             }
@@ -126,13 +124,14 @@
         public <T> AsyncTask<T, ?, ?> submit(Object identifier,
                 AsyncTask<T, ?, ?> task, T... params) {
             synchronized (mNextLock) {
-                checkState(mNextIdentifier == null);
-                checkState(mNextTask == null);
+                Assert.assertNull(mNextIdentifier);
+                Assert.assertNull(mNextTask);
                 mNextIdentifier = identifier;
-                mNextTask = checkNotNull(task, "Already had a valid task.\n"
+                Assert.assertNotNull("Already had a valid task.\n"
                         + "Are you calling AsyncTaskExecutor.submit(...) from within the "
                         + "onPreExecute() method of another task being submitted?\n"
-                        + "Sorry!  Not that's not supported.");
+                        + "Sorry!  Not that's not supported.", task);
+                mNextTask = task;
             }
             return task.executeOnExecutor(this, params);
         }
@@ -205,7 +204,7 @@
 
     private List<SubmittedTask> getSubmittedTasksByIdentifier(
             Object identifier, boolean remove) {
-        Preconditions.checkNotNull(identifier, "can't lookup tasks by 'null' identifier");
+        Assert.assertNotNull(identifier);
         List<SubmittedTask> results = Lists.newArrayList();
         synchronized (mLock) {
             Iterator<SubmittedTask> iter = mSubmittedTasks.iterator();