diff options
author | Yorke Lee <yorkelee@google.com> | 2014-05-28 17:47:33 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2014-05-28 17:49:25 -0700 |
commit | fabd82363920a24be32d68adb5966412c626dea0 (patch) | |
tree | 478e3d4964a979ca234672acd362d4eac409f1ee /tests/src/com | |
parent | 8cb96ebd2a8bc9369f0bcd562a270b8c0c8083df (diff) |
Fix broken Dialer tests
Remove unneeded use of resources
Instantiate CallLogListItemViews correctly
Add dummy number to SmartDialPrefixTests
Change-Id: I3d61c3a6892f3fe84a353cc7617c011aa5124e9a
Diffstat (limited to 'tests/src/com')
4 files changed, 12 insertions, 22 deletions
diff --git a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java index 30fd0e2a7..679335e57 100644 --- a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java +++ b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java @@ -112,8 +112,6 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { setPhoneCallDetailsWithNumber("14125551212", Calls.PRESENTATION_ALLOWED, "1-412-555-1212"); assertTrue(mViews.callLocationAndDate.getText().toString().contains("Yesterday")); - assertTrue(mViews.callLocationAndDate.getText().toString().contains( - "<font color='#33b5e5'><b>Yesterday</b></font>")); } /** Asserts that a char sequence is actually a Spanned corresponding to the expected HTML. */ diff --git a/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java b/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java index 8225d1319..f3679d4ed 100644 --- a/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java @@ -68,7 +68,7 @@ public class CallLogAdapterTest extends AndroidTestCase { mCursor = new MatrixCursor(CallLogQuery._PROJECTION); mCursor.moveToFirst(); // The views into which to store the data. - mView = new View(getContext()); + mView = new CallLogListItemView(getContext()); mView.setTag(CallLogListItemViews.createForTest(getContext())); } diff --git a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java index 2c0fe0e23..964d8a299 100644 --- a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java @@ -91,11 +91,6 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme private Random mRnd; - // References to the icons bitmaps used to build the list are stored in a - // map mIcons. The keys to retrieve the icons are: - // Calls.INCOMING_TYPE, Calls.OUTGOING_TYPE and Calls.MISSED_TYPE. - private HashMap<Integer, Bitmap> mCallTypeIcons; - // An item in the call list. All the methods performing checks use it. private CallLogListItemViews mItem; // The list of views representing the data in the DB. View are in @@ -133,7 +128,6 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme mAdapter.stopRequestProcessing(); mParentView = new FrameLayout(mActivity); mCursor = new MatrixCursor(CallLogQuery._PROJECTION); - buildIconMap(); } /** @@ -412,17 +406,6 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme return d.getBitmap(); } - /** - * Fetch all the icons we need in tests from the contacts app and store them in a map. - */ - private void buildIconMap() { - mCallTypeIcons = new HashMap<Integer, Bitmap>(3); - - mCallTypeIcons.put(Calls.INCOMING_TYPE, getBitmap("ic_call_incoming_holo_dark")); - mCallTypeIcons.put(Calls.MISSED_TYPE, getBitmap("ic_call_missed_holo_dark")); - mCallTypeIcons.put(Calls.OUTGOING_TYPE, getBitmap("ic_call_outgoing_holo_dark")); - } - // // HELPERS to build/update the call entries (views) from the DB. // diff --git a/tests/src/com/android/dialer/database/SmartDialPrefixTest.java b/tests/src/com/android/dialer/database/SmartDialPrefixTest.java index 558be265b..9cb842e56 100644 --- a/tests/src/com/android/dialer/database/SmartDialPrefixTest.java +++ b/tests/src/com/android/dialer/database/SmartDialPrefixTest.java @@ -21,6 +21,8 @@ import android.database.sqlite.SQLiteDatabase; import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.Suppress; import android.test.AndroidTestCase; +import android.text.TextUtils; +import android.util.Log; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Data; @@ -37,7 +39,7 @@ import java.util.ArrayList; /** * To run this test, use the command: - * adb shell am instrument -w -e class com.android.dialer.dialpad.SmartDialPrefixTest / + * adb shell am instrument -w -e class com.android.dialer.database.SmartDialPrefixTest / * com.android.dialer.tests/android.test.InstrumentationTestRunner */ @SmallTest @@ -145,6 +147,12 @@ public class SmartDialPrefixTest extends AndroidTestCase { assertNotNull(contactCursor); assertNotNull(nameCursor); + if (TextUtils.isEmpty(number)) { + // Add a dummy number, otherwise DialerDatabaseHelper simply ignores the entire + // row if the number is empty + number = "0"; + } + contactCursor.addRow(new Object[]{id, "", "", number, contactId, lookupKey, displayName, photoId, lastTimeUsed, timesUsed, starred, isSuperPrimary, inVisibleGroup, isPrimary}); @@ -292,7 +300,8 @@ public class SmartDialPrefixTest extends AndroidTestCase { // 6543 doesn't match assertFalse(getLooseMatchesFromDb("6543").contains(martinjuniorharry)); - assertEquals(7, mTestHelper.countPrefixTableRows(db)); + // 7 actual rows, + 1 for the dummy number we added + assertEquals(8, mTestHelper.countPrefixTableRows(db)); } public void testPutForInitialMatchesForLongTokenNames() { |