diff options
author | Andrew Lee <anwlee@google.com> | 2015-04-09 09:20:49 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2015-04-09 11:19:44 -0700 |
commit | 69748953bc507fc8c02ad401f51b7df2efd77688 (patch) | |
tree | f7a80973e9bd0ed34f7e132c318c4f3190a8214b /tests/src/com | |
parent | fcb5a03fbd4392ca9e159fcb7debf457cb2e739d (diff) |
Move some CallLog testing from adapter to fragment.
- Remove custom testing method formerly in the adapter.
- Remove unused expand animate code.
Bug: 19372817
Change-Id: I78489d63ac9c3324cd80f8039d14a41813772e11
Diffstat (limited to 'tests/src/com')
-rw-r--r-- | tests/src/com/android/dialer/calllog/CallLogFragmentTest.java | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java index 055342250..b57489d55 100644 --- a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java @@ -57,7 +57,7 @@ import java.util.Random; * runtest contacts * or * adb shell am instrument \ - * -w com.android.contacts.tests/android.test.InstrumentationTestRunner + * -w com.android.dialer.tests/android.test.InstrumentationTestRunner */ @LargeTest public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<FragmentTestActivity> { @@ -177,7 +177,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme mCursor.moveToFirst(); insertPrivate(NOW, 0); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindViewForTest(view, getActivity(), mCursor); + bindViewForTest(view, mCursor); } @MediumTest @@ -193,7 +193,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme mCursor.moveToFirst(); insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindViewForTest(view, getActivity(), mCursor); + bindViewForTest(view, mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertNameIs(views, TEST_NUMBER); @@ -207,7 +207,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme values[CallLogQuery.CACHED_FORMATTED_NUMBER] = TEST_FORMATTED_NUMBER; insertValues(values); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindViewForTest(view, getActivity(), mCursor); + bindViewForTest(view, mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertNameIs(views, TEST_FORMATTED_NUMBER); @@ -221,7 +221,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE, "John Doe", Phone.TYPE_HOME, TEST_DEFAULT_CUSTOM_LABEL); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindViewForTest(view, getActivity(), mCursor); + bindViewForTest(view, mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertNameIs(views, "John Doe"); @@ -234,7 +234,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme insertWithCachedValues("sip:johndoe@gmail.com", NOW, 0, Calls.INCOMING_TYPE, "John Doe", Phone.TYPE_HOME, TEST_DEFAULT_CUSTOM_LABEL); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindViewForTest(view, getActivity(), mCursor); + bindViewForTest(view, mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertNameIs(views, "John Doe"); @@ -249,7 +249,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE, "John Doe", Phone.TYPE_HOME, TEST_DEFAULT_CUSTOM_LABEL); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindViewForTest(view, getActivity(), mCursor); + bindViewForTest(view, mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertNameIs(views, "John Doe"); @@ -264,7 +264,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE, "John Doe", Phone.TYPE_WORK, TEST_DEFAULT_CUSTOM_LABEL); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindViewForTest(view, getActivity(), mCursor); + bindViewForTest(view, mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertNameIs(views, "John Doe"); @@ -278,7 +278,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE, "John Doe", Phone.TYPE_CUSTOM, numberLabel); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindViewForTest(view, getActivity(), mCursor); + bindViewForTest(view, mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertNameIs(views, "John Doe"); @@ -291,7 +291,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE, "John Doe", Phone.TYPE_HOME, ""); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindViewForTest(view, getActivity(), mCursor); + bindViewForTest(view, mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertTrue(views.quickContactView.isEnabled()); @@ -302,7 +302,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme mCursor.moveToFirst(); insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindViewForTest(view, getActivity(), mCursor); + bindViewForTest(view, mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); assertFalse(views.quickContactView.isEnabled()); @@ -313,7 +313,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme mCursor.moveToFirst(); insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindViewForTest(view, getActivity(), mCursor); + bindViewForTest(view, mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); @@ -334,7 +334,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme mCursor.moveToFirst(); insertVoicemail(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0); View view = mAdapter.newStandAloneView(getActivity(), mParentView); - mAdapter.bindViewForTest(view, getActivity(), mCursor); + bindViewForTest(view, mCursor); CallLogListItemViews views = (CallLogListItemViews) view.getTag(); IntentProvider intentProvider = (IntentProvider) views.voicemailButtonView.getTag(); @@ -424,7 +424,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme if (null == mList[i]) { mList[i] = mAdapter.newStandAloneView(mActivity, mParentView); } - mAdapter.bindViewForTest(mList[i], mActivity, mCursor); + bindViewForTest(mList[i], mCursor); mCursor.moveToPrevious(); i++; } @@ -442,6 +442,19 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme // /** + * Bind a call log entry view for testing purposes. Also inflates the action view stub so + * unit tests can access the buttons contained within. + * + * @param view The current call log row. + * @param cursor The cursor to bind from. + */ + private void bindViewForTest(View view, MatrixCursor cursor) { + mAdapter.bindView(view, cursor, /* count */ 1); + CallLogListItemViews views = (CallLogListItemViews) view.getTag(); + mAdapter.expandItem(views, /* expand */ true); + } + + /** * Insert a certain number of random numbers in the DB. Makes sure * there is at least one private and one unknown number in the DB. * @param num Of entries to be inserted. |