summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2015-04-02 17:23:33 -0700
committerAndrew Lee <anwlee@google.com>2015-04-03 15:16:07 -0700
commit74479d448bc39c3534585a627fba603aa89e93ca (patch)
treedadd489fbfa83cf3eb7fde9bc89010504c13a9a2 /tests
parent0d27e1d231226e6ca5e7ed51225f7886598b05b0 (diff)
downloadandroid_packages_apps_Dialer-74479d448bc39c3534585a627fba603aa89e93ca.tar.gz
android_packages_apps_Dialer-74479d448bc39c3534585a627fba603aa89e93ca.tar.bz2
android_packages_apps_Dialer-74479d448bc39c3534585a627fba603aa89e93ca.zip
Create ContactInfoCache from CallLogAdapter.
This pulls code from the CallLogAdapter, with only tweaks to variable names and comments, to create a ContactInfoCache responsible for logic pertaining to looking up and caching contact info. The logic is intended to be unchanged for now, although in the future it can/should probably be cleaned up sometime. Bug: 20038300 Change-Id: I60a57b0a665496522a6b51c9e6e41a4fd6dbad1f
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogAdapterTest.java41
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogFragmentTest.java2
2 files changed, 28 insertions, 15 deletions
diff --git a/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java b/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java
index 0f175117d..dbdde6875 100644
--- a/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java
@@ -23,6 +23,8 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.view.View;
import android.widget.LinearLayout;
+import com.android.dialer.contactinfo.ContactInfoCache;
+import com.android.dialer.contactinfo.ContactInfoCache.OnContactInfoChangedListener;
import com.google.common.collect.Lists;
import java.util.List;
@@ -88,9 +90,9 @@ public class CallLogAdapterTest extends AndroidTestCase {
mAdapter.bindStandAloneView(mView, getContext(), mCursor);
// There is one request for contact details.
- assertEquals(1, mAdapter.requests.size());
+ assertEquals(1, mAdapter.getContactInfoCache().requests.size());
- TestCallLogAdapter.Request request = mAdapter.requests.get(0);
+ TestContactInfoCache.Request request = mAdapter.getContactInfoCache().requests.get(0);
// It is for the number we need to show.
assertEquals(TEST_NUMBER, request.number);
// It has the right country.
@@ -106,9 +108,9 @@ public class CallLogAdapterTest extends AndroidTestCase {
mAdapter.bindStandAloneView(mView, getContext(), mCursor);
// There is one request for contact details.
- assertEquals(1, mAdapter.requests.size());
+ assertEquals(1, mAdapter.getContactInfoCache().requests.size());
- TestCallLogAdapter.Request request = mAdapter.requests.get(0);
+ TestContactInfoCache.Request request = mAdapter.getContactInfoCache().requests.get(0);
// The values passed to the request, match the ones in the call log cache.
assertEquals(TEST_NAME, request.callLogInfo.name);
assertEquals(1, request.callLogInfo.type);
@@ -124,9 +126,9 @@ public class CallLogAdapterTest extends AndroidTestCase {
mAdapter.bindStandAloneView(mView, getContext(), mCursor);
// There is one request for contact details.
- assertEquals(1, mAdapter.requests.size());
+ assertEquals(1, mAdapter.getContactInfoCache().requests.size());
- TestCallLogAdapter.Request request = mAdapter.requests.get(0);
+ TestContactInfoCache.Request request = mAdapter.getContactInfoCache().requests.get(0);
// Since there is something in the cache, it is not an immediate request.
assertFalse("should not be immediate", request.immediate);
}
@@ -139,7 +141,7 @@ public class CallLogAdapterTest extends AndroidTestCase {
mAdapter.bindStandAloneView(mView, getContext(), mCursor);
// Cache and call log are up-to-date: no need to request update.
- assertEquals(0, mAdapter.requests.size());
+ assertEquals(0, mAdapter.getContactInfoCache().requests.size());
}
public void testBindView_MismatchBetwenCallLogAndMemoryCache_EnqueueRequest() {
@@ -154,9 +156,9 @@ public class CallLogAdapterTest extends AndroidTestCase {
mAdapter.bindStandAloneView(mView, getContext(), mCursor);
// There is one request for contact details.
- assertEquals(1, mAdapter.requests.size());
+ assertEquals(1, mAdapter.getContactInfoCache().requests.size());
- TestCallLogAdapter.Request request = mAdapter.requests.get(0);
+ TestContactInfoCache.Request request = mAdapter.getContactInfoCache().requests.get(0);
// Since there is something in the cache, it is not an immediate request.
assertFalse("should not be immediate", request.immediate);
}
@@ -191,9 +193,20 @@ public class CallLogAdapterTest extends AndroidTestCase {
/**
* Subclass of {@link CallLogAdapter} used in tests to intercept certain calls.
*/
- // TODO: This would be better done by splitting the contact lookup into a collaborator class
- // instead.
private static final class TestCallLogAdapter extends CallLogAdapter {
+ public TestCallLogAdapter(Context context, CallFetcher callFetcher,
+ ContactInfoHelper contactInfoHelper) {
+ super(context, callFetcher, contactInfoHelper, null, null);
+ mContactInfoCache = new TestContactInfoCache(
+ contactInfoHelper, mOnContactInfoChangedListener);
+ }
+
+ public TestContactInfoCache getContactInfoCache() {
+ return (TestContactInfoCache) mContactInfoCache;
+ }
+ }
+
+ private static final class TestContactInfoCache extends ContactInfoCache {
public static class Request {
public final String number;
public final String countryIso;
@@ -211,9 +224,9 @@ public class CallLogAdapterTest extends AndroidTestCase {
public final List<Request> requests = Lists.newArrayList();
- public TestCallLogAdapter(Context context, CallFetcher callFetcher,
- ContactInfoHelper contactInfoHelper) {
- super(context, callFetcher, contactInfoHelper, null, null);
+ public TestContactInfoCache(
+ ContactInfoHelper contactInfoHelper, OnContactInfoChangedListener listener) {
+ super(contactInfoHelper, listener);
}
@Override
diff --git a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java
index 5d9a05f83..055342250 100644
--- a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java
@@ -126,7 +126,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
// Do not process requests for details during tests. This would start a background thread,
// which makes the tests flaky.
mAdapter.disableRequestProcessingForTest();
- mAdapter.stopRequestProcessing();
+ mAdapter.pauseCache();
mParentView = new FrameLayout(mActivity);
mCursor = new MatrixCursor(CallLogQuery._PROJECTION);
}